home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / Others / UnixCourse / BourneShell.txt < prev    next >
Text File  |  1992-03-27  |  598KB  |  10,979 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                    UNIX Bourne Shell Programming
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.                     Developed by:
  41.  
  42.                          User Liaison Section, D-7131
  43.                          Denver Office
  44.    
  45.                     [Name and number removed at author's
  46.                      request]
  47.  
  48.                     Revision Date:  February 7, 1991
  49.  
  50.  
  51. I.  INTRODUCTION..............................................  v
  52.      A.  Audience.............................................  v
  53.      B.  Course Objectives....................................  v
  54.      C.  Course Handout Conventions........................... vi
  55.  
  56. 1.  BOURNESHELL OVERVIEW......................................  1
  57.      1.1  What is the BourneShell?............................  2
  58.      1.2  Making a Bourne Shell Script Executable.............  3
  59.      1.3  Tracing Mechanisms..................................  6
  60.      Workshop 1...............................................  9
  61.  
  62. 2.  USER, SHELL, AND READ-ONLY SHELL VARIABLES................ 11
  63.      2.1  User Variables...................................... 11
  64.      2.2  Shell Variables..................................... 14
  65.           2.2.1  HOME......................................... 14
  66.           2.2.2  IFS.......................................... 15
  67.           2.2.3  MAIL......................................... 15
  68.           2.2.4  MAILPATH..................................... 15
  69.           2.2.5  MAILCHECK.................................... 16
  70.           2.2.6  PATH......................................... 16
  71.           2.2.7  PS1.......................................... 17
  72.           2.2.8  PS2.......................................... 17
  73.      2.3  Read-Only User Variables............................ 18
  74.      2.4  Read-Only Shell Variables........................... 19
  75.           2.4.1  Name of the Calling Program.................. 19
  76.           2.4.2  Arguments.................................... 19
  77.           2.4.3  Shift........................................ 21
  78.           2.4.4  Set.......................................... 22
  79.           2.4.5  expr......................................... 23
  80.      Workshop 2............................................... 27
  81.  
  82. 3.  POSITIONAL PARAMETERS..................................... 33
  83.      3.1  Reading Input Into a Shell Variable................. 34
  84.      3.2  Command Substitution................................ 36
  85.      3.3  Comments in BourneShell Scripts..................... 38
  86.      3.4  BourneShell Environment - Exporting Variables....... 39
  87.      Workshop 3............................................... 41
  88.  
  89. 4.  CONTROL CONSTRUCTS:....................................... 45
  90.      4.1  Types of Tests Used with Control Constructs:........ 46
  91.      4.2  Test on Numeric Values.............................. 47
  92.      4.3  Test on Character Strings........................... 47
  93.      4.4  Test on File Types.................................. 49
  94.      4.5  if then............................................. 50
  95.      4.6  if then else........................................ 52
  96.      4.7  if then elif........................................ 54
  97.      4.8  for................................................. 55
  98.      4.9  while............................................... 57
  99.      4.10  until.............................................. 58
  100.      4.11  case............................................... 60
  101.      Workshop 4............................................... 63
  102.  
  103. 5. COMPILING PROGRAMS IN UNIX................................. 67
  104.      5.1  "C": Sample Program with a Main and Two Functions
  105.                in One        ................................. 67
  106.      5.2  "C": Compiling a Program............................ 69
  107.      5.3  "C": Renaming the Executable Module................. 71
  108.      5.4  "C": Giving a Name to the Output File............... 72
  109.      5.5  "C": Producing an Assembly Listing.................. 73
  110.      5.6  "C": Main and Two Functions in Three Separate Source
  111.                Files.......................................... 74
  112.      5.7  "C": Compiling but Not Producing an Executable    
  113.            Module............................................. 75
  114.      5.8  FORTRAN: Sample Program a Main and Two Subroutine... 76
  115.      5.9  FORTRAN: Compiling a Program........................ 77
  116.      5.10  FORTRAN: Renaming the Executable Module............ 79
  117.      5.11  FORTRAN: Giving a Name to the Output File.......... 80
  118.      5.12  FORTRAN: Producing an Assembly Listing............. 81
  119.      5.13  FORTRAN: Main and Two Subroutines in Three Separate
  120.                     Source Files.............................. 82
  121.      5.14  FORTRAN: Compiling But Not Producing an Executable
  122.                     Module.................................... 83
  123.      5.15  FORTRAN: Compiling Object Files to Produce an    
  124.                 Executable Module............................. 84
  125.      5.16  COBOL: Sample Program with a Main and Two        
  126.                   Subroutines................................. 85
  127.      5.17  COBOL: Compiling a Program......................... 86
  128.      5.18  COBOL: Running a Program........................... 87
  129.      Workshop 5............................................... 89
  130.  
  131. 6.  UNIX TOOLS................................................ 95
  132.      6.1  Processes........................................... 95
  133.      6.2  Executing a Command................................. 95
  134.      6.3  Process Identification.............................. 95
  135.      6.4  grep: A Pattern Matching Filter..................... 98
  136.           6.4.1  More on Regular Expressions.................. 99
  137.           6.4.2  Closure......................................103
  138.           6.4.3  Some Nice grep Options ......................104
  139.           6.4.4  Summary of Regular Expression Characters.....105
  140.      6.5  sed: Edit a File to Standard Output.................106
  141.      6.6  awk: A Pattern Matching Programming Language........110
  142.      6.7  sort: Sort a File...................................114
  143.      6.8  What Other Useful UNIX Tools are Available..........117
  144.      6.9  Archiver and Library Maintainer.....................118
  145.           6.9.1  ar: Creating an Archive File with Object   
  146.                   Modules.....................................119
  147.           6.9.2  ar: Verifying the Contents of the Archive  
  148.                    File.......................................119
  149.           6.9.3  ar: Removing Duplicate Object Files..........120
  150.           6.9.4  ar: Compiling Main and Archive Files.........120
  151.      Workshop 6...............................................121
  152.  
  153.  
  154. 7.  VAX DCL TO UNIX SHELL SCRIPT CONVERSION...................125
  155.      7.1  Processes...........................................127
  156.      7.2  Pipes...............................................128
  157.      7.3  Input, Output, and Error Redirection................129
  158.      7.4  Command Structure and File Naming Conventions.......131
  159.      7.5  File Management Commands............................133
  160.      7.6  Metacharacters......................................135
  161.      7.7  Wildcards: Are They Really Wild?....................136
  162.      7.8  Summary.............................................137
  163.      Workshop 7...............................................139
  164.  
  165. 8.  ADVANCED FEATURES OF FTP..................................143
  166.      8.1  Initializing FTP on UMAX............................144
  167.      8.2  Multiple File Transfers.............................145
  168.      8.3  Auto Login Feature..................................146
  169.      8.4  Macros..............................................148
  170.      8.5  Filename Translation................................149
  171.      8.6  Aborting Transfers..................................150
  172.      8.7  More Remote Computer Commands.......................151
  173.      Workshop 8...............................................153
  174.  
  175. 9.  OPTIONAL CHAPTER - KORNSHELL PROGRAMMING..................155
  176.      9.1  KornShell Variables.................................155
  177.      9.2  User Defined Variables..............................157
  178.      9.3  Values of Variables Between Child and Parent
  179.           Processes...........................................158
  180.      9.4  ksh: Aliases........................................159
  181.      9.5  ksh: Command Line Editing...........................161
  182.      9.6  ksh: Interactive Command Line Editing...............162
  183.      9.7  ksh: Functions......................................164
  184.      9.8  ksh: The Select Construct...........................166
  185.      9.9  ksh: Tracing and Conditional Execution..............168
  186.      Workshop 9...............................................169
  187.  
  188. APPENDIX A - sh...............................................173
  189.  
  190. APPENDIX B - test.............................................189
  191.  
  192. APPENDIX C - expr.............................................193
  193.  
  194. APPENDIX D - ftp..............................................195
  195.  
  196. APPENDIX E - cc...............................................209
  197.  
  198. APPENDIX F - f77..............................................219
  199.  
  200. APPENDIX G - lint.............................................231
  201.  
  202. APPENDIX H - cb...............................................235
  203.  
  204. APPENDIX I - ar...............................................237
  205.  
  206. APPENDIX J - time.............................................243
  207.  
  208. APPENDIX K - ksh..............................................245
  209.  
  210. INDEX.........................................................279
  211.  
  212. I.  INTRODUCTION
  213.  
  214.  
  215. A.  Audience
  216.  
  217.  
  218. This course is for individuals who have completed "UNIX for
  219. Beginning Users" (or equivalent experience) and want to write UNIX
  220. BourneShell script files.  A script file contains a sequence of
  221. UNIX commands which can be executed by entering one command.  It
  222. is assumed that the student already has a good understanding of the
  223. UNIX operating system, be able to use a UNIX editor, and be
  224. familiar with a computer terminal or typewriter keyboard.
  225.  
  226.  
  227.  
  228. B.  Course Objectives
  229.  
  230.  
  231. Upon successful completion of this course the student will be able
  232. to:
  233.  
  234.      1.   Write moderately complex BourneShell scripts.
  235.  
  236.      2.   Make a BourneShell script executable.
  237.  
  238.      3.   Demonstrate how to use the following BourneShell
  239.           commands: shift, exit, expr, test, if then, if then else,
  240.           if then elif, for, while, until, and case.
  241.  
  242.      4.   Use the following BourneShell constructs: tracing
  243.           mechanisms (for debugging), user variables, BourneShell
  244.           variables, read-only variables, positional parameters,
  245.           reading input to a BourneShell script, command
  246.           substitution, comments, and exporting variables.  In
  247.           addition, test on numeric values, test on file type, and
  248.           test on character strings are covered.
  249.  
  250.      6.   Create a ".profile" script to customize the user
  251.           environment.
  252.  
  253.      7.   Use advanced features of File Transfer Protocol (FTP)
  254.  
  255.      8.   Compile source code into object and executable modules.
  256.  
  257.      9.   Optional: KornShell programming.  This is of primary
  258.           interest to programmers.
  259.  
  260.      10.  Convert VMS DCL command files to UNIX Shell.
  261. C.  Course Handout Conventions
  262.  
  263.  
  264. There are several conventions used in this handout for consistency
  265. and easier interpretation:
  266.  
  267.  
  268.      1.   Samples of actual terminal sessions are single-lined
  269.           boxed.
  270.  
  271.  
  272.      2.   User entries are shown in bold print and are underlined.
  273.  
  274.           exit
  275.  
  276.  
  277.      3.   All keyboard functions in the text will be bold.  
  278.  
  279.           (Ret)               Backspace
  280.           Tab                 Ctrl-F6
  281.           Print (Shift-F7)    Go to DOS (1)
  282.  
  283.           NOTE:     (Ret) indicates the Return or Enter key located
  284.                     above the right Shift key.
  285.  
  286.  
  287.      4.   Examples of user entries not showing the computer's
  288.           response are in dotted-lined boxes.                   
  289.            
  290.  
  291.  
  292.      5.   Command formats are double-lined boxed.
  293.  
  294.  
  295.  
  296.      6.   Three dots either in vertical or horizontal alignment
  297.           mean continuation or that data is missing from diagram.
  298.  
  299.                                                                  
  300. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  301. ‡                                                               ‡
  302. ‡        Multimax, Nanobus, and UMAX are trademarks of          ‡
  303. ‡        Encore Computer Corporation.                           ‡
  304. ‡                                                               ‡
  305. ‡                                                               ‡
  306. ‡        Annex is a trademark of XYLOGICS, Inc.                 ‡
  307. ‡                                                               ‡
  308. ‡                                                               ‡
  309. ‡        UNIX and Teletype are registered trademarks of         ‡
  310. ‡        AT&T Bell Laboratories                                 ‡
  311. ‡                                                               ‡
  312. ‡                                                               ‡
  313. ‡        Ethernet is a trademark of Xerox Corporation           ‡
  314. ‡                                                               ‡
  315. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  316.                                NOTES
  317. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  318. 1.  BOURNESHELL OVERVIEW
  319.  
  320.  
  321. The BourneShell is both a command-line interpreter and a high-
  322. level programming language.  When it is acting as a command-line
  323. interpreter, it processes commands as you enter them at the command
  324. prompt.  When you use it as a programming language, it processes
  325. commands that are stored in files known as BourneShell scripts. 
  326. This course will show you how to create and execute BourneShell
  327. scripts.  We will explore BourneShell programming including such
  328. features as variables, control structures, processes, and
  329. executable files.
  330.  
  331.  
  332. The BourneShell is one of three shells available on most UNIX
  333. systems.  Bourne is the accepted standard for System V UNIX.  The
  334. other shells are being used more and more.  The other shells are
  335. the CShell and the KornShell.  The CShell is BSD (Berkeley Software
  336. Distribution) UNIX. BSD was developed at the University of
  337. California at Berkeley, California. Most of the features found in
  338. the BourneShell are also found in the other shells; there are
  339. differences, however.  The CShell and KornShell are not standard
  340. on UNIX System V but are generally available.
  341.  
  342.  
  343. BourneShell scripts allow you to group command lines together and
  344. execute them by entering a single command at the command line. This
  345. allows complex functions to be completed by any user, and
  346. repetitive functions can be completed easily.  Input and output
  347. can also be redirected from a BourneShell script.
  348. 1.1  What is the BourneShell?
  349.  
  350. BourneShell is a high level programming language and a command line
  351. interpreter. 
  352.  
  353. The command to invoke the BourneShell is:
  354.  
  355. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  356. ”  Command Format:  sh [-acefhiknrstuvx] [args]                 ”
  357. ”                                                               ”
  358. ”  (See Appendix A for a complete list of options etc)          ”
  359. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  360.  
  361. A Shell script is an executable plain file that contains UNIX and
  362. shell commands. To execute the shell script type the name of the
  363. script at the prompt. A simple shell script called shell_ex is
  364. shown in the following example. The output from the execution of
  365. the shell is also shown.
  366.  
  367. Sample Session:
  368.  
  369. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  370. ‡ $cat shell_ex                                                 ‡
  371. ‡ echo "This is a very simple shell procedure "                 ‡
  372. ‡ echo "created with the basic echo command "                   ‡
  373. ‡ echo "and three other very basic commands "                   ‡
  374. ‡ echo                                                          ‡
  375. ‡ ps                                                            ‡
  376. ‡ echo                                                          ‡ 
  377. ‡ who                                                           ‡
  378. ‡ echo                                                          ‡
  379. ‡ ls                                                            ‡
  380. ‡ $sh shell_ex                                                  ‡
  381. ‡ This is a very simple shell procedure                         ‡
  382. ‡ created with the very basic echo command                      ‡
  383. ‡ and three other very basic commands                           ‡
  384. ‡                                                               ‡
  385. ‡ PID    TTY     TIME    COMMAND                                ‡
  386. ‡ 10443 rt02120  0:01    sh                                     ‡
  387. ‡ 10427 rt02120  0:04    ksh                                    ‡
  388. ‡                                                               ‡
  389. ‡ sgavlick  rt021e0   Sep 7   13:26                             ‡
  390. ‡ teacher   rt021b0   Sep 7   14:39                             ‡
  391. ‡                                                               ‡
  392. ‡ memo                                                          ‡
  393. ‡ class_notes                                                   ‡
  394. ‡ $                                                             ‡
  395. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  396. 1.2  Making a Bourne Shell Script Executable
  397.  
  398. A BourneShell script is an ordinary file that contains commands
  399. which can be executed in sequence by entering one command at the
  400. BourneShell prompt.  In order for a script to be executed, it must
  401. first be executable.  This is done with the chmod command.
  402.  
  403. Sample Session:
  404.  
  405. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  406. ‡ $cat shell_ex                                                 ‡
  407. ‡ echo "This is a very simple shell procedure "                 ‡
  408. ‡ echo "created with the basic echo command "                   ‡
  409. ‡ echo "and three other very basic commands "                   ‡
  410. ‡ echo                                                          ‡
  411. ‡ ps                                                            ‡
  412. ‡ echo                                                          ‡
  413. ‡ who                                                           ‡
  414. ‡ echo                                                          ‡
  415. ‡ ls                                                            ‡
  416. ‡ $                                                             ‡
  417. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  418.  
  419. If the ls -l shell_ex command were entered, we would see the
  420. protections assigned to this file.
  421.  
  422. Sample Session:
  423.  
  424. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  425. ‡ $ls -l shell_ex                                               ‡
  426. ‡ -rw-r--r-- 1 teacher class  66 Sep 7 10:24 shell_ex           ‡
  427. ‡ $                                                             ‡
  428. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  429.  
  430. The character in column one is the type of file. 
  431.  
  432.       -  =  ordinary (plain) disk file
  433.  
  434.       d  =  directory
  435.  
  436.       b  =  block special file
  437.  
  438.       c  =  character special file
  439.  
  440.       p  =  fifo file ("named pipe") special file
  441.  
  442.       l  =  symbolic link
  443.  
  444.           
  445.  
  446.  
  447.  
  448. Notice that the script file in the previous sample session has the
  449. following file protections:
  450.  
  451.      User   - Read and Write
  452.      Group  - Read
  453.      Other  - Read
  454.  
  455. No execute permissions have been granted for user, group, or other. 
  456. If we try to execute this script by typing its name, the following
  457. would result.
  458.  
  459. Sample Session:
  460.  
  461. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  462. ‡ $shell_ex                                                     ‡
  463. ‡ shell_ex: execute permission denied                           ‡
  464. ‡ $                                                             ‡
  465. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  466.  
  467. This error message would indicate that execute permission was
  468. denied.  The BourneShell script could not be executed.  To change
  469. the permissions for the BourneShell script, use the chmod command.
  470.  
  471. Sample Session:
  472.  
  473. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  474. ‡ $chmod 755 shell_ex                                           ‡
  475. ‡ $ls -l shell_ex                                               ‡
  476. ‡ -rwxr-xr-x 1 teacher class  66 Sep 7  10:26 shell_ex          ‡
  477. ‡ $                                                             ‡
  478. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  479.  
  480.  
  481. Now that the permissions have been changed to allow user, group,
  482. and others to execute the file, it will execute properly.
  483. Sample Session:
  484.  
  485. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  486. ‡ $shell_ex                                                     ‡
  487. ‡ This is a very simple shell procedure                         ‡
  488. ‡ created with the basic echo command                           ‡
  489. ‡ and three other very basic commands                           ‡
  490. ‡                                                               ‡
  491. ‡ PID    TTY     TIME    COMMAND                                ‡
  492. ‡ 10443 rt02120  0:01    sh                                     ‡
  493. ‡ 10427 rt02120  0:04    ksh                                    ‡
  494. ‡                                                               ‡
  495. ‡ sgavlick  rt021e0   Sep 7   13:26                             ‡
  496. . teacher   rt021b0   Sep 7   14:39                             .
  497. .                                                               .
  498. .                                                               .
  499.  
  500.  
  501. The protections will work as you expect.  Execute permission for
  502. the user will allow you (the owner) to run the BourneShell script.
  503. Group permissions allow anyone in your group to execute the script,
  504. and other permission allows anyone on the system to execute the
  505. script.
  506. 1.3  Tracing Mechanisms
  507.  
  508. It is possible to have a trace made of the BourneShell script as
  509. it executes. This is invaluable for debugging purposes. All that
  510. is required is to give an option to the BourneShell.   This is done
  511. by including an option on the call to "sh". The command to do this
  512. is:
  513.  
  514. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  515. ”     Command Format: sh [-acefhiknrstuvx] [args]               ”
  516. ”                                                               ”
  517. ”     See Appendix A for a complete list of options etc         ”
  518. ”                                                               ”
  519. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  520.  
  521. The option to turn on tracing is -x. For an example, let's trace
  522. the execution of the simple script shell_ex.
  523.  
  524. Sample session:
  525.  
  526. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  527. ‡     $cat shell_ex                                             ‡
  528. ‡     echo "This is a very simple shell procedure "             ‡
  529. ‡     echo "created with the basic echo command "               ‡
  530. ‡     echo "and three other very basic commands "               ‡
  531. ‡     echo                                                      ‡
  532. ‡     ps                                                        ‡
  533. ‡     echo                                                      ‡
  534. ‡     who                                                       ‡
  535. ‡     echo                                                      ‡
  536. ‡     ls                                                        ‡
  537. ‡     $                                                         ‡
  538. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  539.  
  540. Execute the BourneShell script using the -x option on the call to
  541. the shell. The following sample session shows how to do this and
  542. it shows the results of the trace.
  543. Sample session:
  544.  
  545. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  546. ‡     $sh -x shell_ex                                           ‡
  547. ‡     + echo This is a very simple shell procedure              ‡
  548. ‡     This is a very simple shell procedure                     ‡
  549. ‡     + echo created with the basic echo command                ‡
  550. ‡     created with the basic echo command                       ‡
  551. ‡     + echo and three other very basic commands                ‡
  552. ‡     and three other very basic commands                       ‡
  553. ‡     + echo                                                    ‡
  554. ‡                                                               ‡
  555. ‡     + ps                                                      ‡
  556. ‡     PID    TTY      TIME       COMMAND                        ‡
  557. ‡     10443 rt01120   0:01       sh                             ‡
  558. ‡     10427 rt02120   0:04       ksh                            ‡
  559. ‡     + echo                                                    ‡
  560. ‡                                                               ‡
  561. ‡     + who                                                     ‡
  562. ‡     sgavlick  rt021e0   Sep 7  13:26                          ‡
  563. ‡     teacher   rt02120   Sep 7  14:39                          ‡
  564. ‡     + echo                                                    ‡
  565. ‡                                                               ‡
  566. ‡     + ls                                                      ‡
  567. ‡     memo                                                      ‡
  568. ‡     class_notes                                               ‡
  569. ‡     $                                                         ‡
  570. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  571.  
  572. The commands as read from the BourneShell script are indicated by
  573. the plus sign (+). The next line or lines are the results of the
  574. execution of the command. Using this tracing option allows you to
  575. se the execution of each command in the script and see the results
  576. of that execution.
  577.                                NOTES
  578. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  579. Workshop 1
  580.  
  581. This workshop will reinforce your understanding of the ideas
  582. presented in Chapter 1. Each student is to complete the entire
  583. workshop.
  584.  
  585. DESK EXERCISES 
  586.  
  587.  
  588.      1.   The BourneShell can act as a command line
  589.  
  590.                                                    
  591.  
  592.           or a high level                          .  
  593.  
  594.  
  595.  
  596.  
  597.      2.   The BourneShell is one of three shells generally
  598.           available. What are the other two?
  599.  
  600.  
  601.  
  602.  
  603.      3.   One advantage of using a shell script is
  604.  
  605.                                                   .
  606.  
  607.  
  608.  
  609.      4.   The command to call the BourneShell is:
  610.  
  611.           a.   bourne
  612.           b.   ksh
  613.           c.    b
  614.           d.   sh
  615.  
  616.  
  617.  
  618.  
  619.      5.   Why would you use tracing?
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.      6.   What UNIX command do you enter to make a BourneShell
  627.           script executable? 
  628.  
  629.  
  630.      That's all
  631.                                NOTES
  632. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  633. 2.  USER, SHELL, AND READ-ONLY SHELL VARIABLES
  634.  
  635.  
  636. The BourneShell has no true numeric variables.  It uses string
  637. variables to represent numbers, as well as text.  String variables
  638. are able to take on the value of a string of characters.  There are
  639. three types of variables in the BourneShell.  They are user
  640. variables, BourneShell variables, and Read-only BourneShell
  641. variables.
  642.  
  643. You can declare, initialize, read, and modify user variables from
  644. a BourneShell script or from the command line.  The BourneShell
  645. itself declares and initializes shell variables, but you can read
  646. and modify them.  The BourneShell also initializes the read-only
  647. shell variables, and you can read but not modify them.
  648.  
  649.  
  650.  
  651. 2.1  User Variables
  652.  
  653.  
  654. It is legal to assign any sequence of non-blank characters as the
  655. name of a variable.  The sample session below creates a variable
  656. called person and initializes it with the string Richard.
  657.  
  658. It is important to note that you must NOT precede or follow the
  659. equal sign with a space or TAB character.
  660.  
  661. Sample Session:
  662.                         
  663. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  664. ‡  $person=Richard                                              ‡
  665. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  666.                                                                  
  667.  
  668. This sample session indicates that person does not represent the 
  669. string Richard.  The string person is echoed as person.  The
  670. BourneShell will only do the substitution of the value of the
  671. variable when the name of the variable is preceded with a dollar
  672. sign ($).  
  673.  
  674. Sample Sesssion:
  675.                 
  676. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  677. ‡  $echo person                                                 ‡
  678. ‡  person                                                       ‡
  679. ‡  $echo $person                                                ‡
  680. ‡  Richard                                                      ‡
  681. ‡  $                                                            ‡
  682. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  683. If you want to have imbedded spaces in a variable, it is necessary
  684. to quote the string.
  685.  
  686. Sample Session:
  687.  
  688. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  689. ‡  $person='Richard and Kathleen'                               ‡
  690. ‡  $echo $person                                                ‡
  691. ‡  Richard and Kathleen                                         ‡
  692. ‡  $                                                            ‡
  693. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  694.  
  695. The echo utility copies its arguments to the standard output.  The
  696. command echo $person displays the value of the variable person. 
  697. It will not display $person because the BourneShell doesn't pass
  698. $person as an argument.  The leading dollar sign ($) causes the
  699. BourneShell to substitute the value of the variable and then passes
  700. that value to the utility.  The echo utility then displays the
  701. value of the variable, not its name, never knowing that you called
  702. it with a variable.  The BourneShell passed the same command line
  703. as if you had typed in echo Richard and Kathleen.  The BourneShell
  704. can be prevented from doing this substitution by entering one of
  705. the following:
  706.  
  707. Sample Sessions:
  708.  
  709. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  710. ‡  $echo $person                                                ‡
  711. ‡  Richard and Kathleen                                         ‡
  712. ‡  $                                                            ‡
  713. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  714.                                                                  
  715. In this session the contents of the variable person are displayed.
  716. The BourneShell made the substitution because the variable name
  717. person is preceded by a dollar sign ($).
  718.  
  719. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  720. ‡  $echo \$person                                               ‡
  721. ‡  $person                                                      ‡
  722. ‡  $                                                            ‡
  723. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  724.  
  725. In the above example the variable person is preceded by a dollar
  726. sign ($) but the dollar sign has a backslash (\) ahead of it. The
  727. backslash has the effect of cancelling the special meaning of the
  728. character following the backslash. In this case, the special
  729. meaning of the dollar sign is ignored and the substitution is not
  730. done.
  731.  
  732.  
  733.  
  734.  
  735. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  736. ‡  $echo '$person'                                              ‡
  737. ‡  $person                                                      ‡
  738. ‡  $                                                            ‡
  739. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  740.  
  741.  
  742. The single quote marks (') causes the characters between the marks
  743. to be taken as literal. The shell makes no attempt to interpret the
  744. meanings of these characters. The shell passes these characters on
  745. with no substitution. 
  746.  
  747. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  748. ‡  $echo "$person"                                              ‡
  749. ‡  Richard and Kathleen                                         ‡
  750. ‡  $                                                            ‡
  751. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  752.  
  753. The double quote marks do not prevent the shell from making
  754. substitution; and the value of the variable will be displayed by
  755. the utility.
  756. 2.2  Shell Variables
  757.  
  758.  
  759. The BourneShell declares and initializes variables that determine
  760. such things as your home directory, what directories the shell will
  761. look in when you give commands, how often to look for mail, your
  762. prompt, and many other things.  We will look at several of these
  763. BourneShell variables and their functions.  You can assign new
  764. values to these variables from the command line or from the
  765. execution of the .profile file in your home directory.
  766.  
  767. 2.2.1  HOME
  768.  
  769. The first BourneShell variable that we will look at is the HOME
  770. variable.  By default, the home directory is the current working
  771. directory after you login.  The system administrator determines
  772. your home directory when you establish an account and places that
  773. information in the /etc/passwd file.  When you login, the
  774. BourneShell gets that pathname and assigns it to the HOME variable.
  775.  
  776. When you enter a cd command with no argument, the utility takes
  777. the name of the directory from the HOME variable and makes it the
  778. current working directory.  If you change the HOME variable to
  779. another directory pathname, the utility will make the new directory
  780. the current working directory.
  781.  
  782. Sample Session:
  783.  
  784. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  785. ‡ $echo $HOME                                                   ‡
  786. ‡ /user0/rharding                                               ‡
  787. ‡ $cd                                                           ‡
  788. ‡ $pwd                                                          ‡
  789. ‡ /user0/rharding                                               ‡
  790. ‡ $HOME=/user0/rharding/eng                                     ‡
  791. ‡ $cd                                                           ‡
  792. ‡ $pwd                                                          ‡
  793. ‡ /user0/rharding/eng                                           ‡
  794. ‡ $                                                             ‡
  795. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  796.  
  797. This example shows how the value of the HOME variable affects the
  798. cd utility.  The cd command will use the value of the HOME variable
  799. as the pathname for the current working directory.
  800. 2.2.2  IFS
  801.  
  802. This is the internal-field separator BourneShell variable.  You
  803. can always use a space or tab to separate characters on the command
  804. line.  When you assign the IFS variable to another character, you
  805. can also use this character as the field separator.
  806.  
  807. Example:
  808. .................................................................
  809. . $num_args a:b:c:d                                             .
  810. .................................................................
  811.  
  812. This example shows only one argument, namely a:b:c:d.
  813. .................................................................
  814. .  $IFS=:                                                       .
  815. .  $num_args a:b:c:d                                            .
  816. .................................................................
  817.  
  818. This example now shows four different arguments; each being
  819. separated by the new IFS, (:).
  820.  
  821. 2.2.3  MAIL
  822.  
  823. The MAIL variable contains the name of the file that the mail (and
  824. mailx) utilities use to store your mail.  Usually, the absolute
  825. pathname of this file is /usr/mail/name, where name is your login
  826. name.
  827.  
  828. Example:
  829. .................................................................
  830. . $MAIL=/usr/mail/rharding                                      .
  831. .................................................................
  832.  
  833. 2.2.4  MAILPATH
  834.  
  835. This variable contains a list of filenames separated by colons. If
  836. set, the BourneShell will inform you when any of these files are
  837. modified (i.e. when new mail arrives).  Normally, this variable is
  838. not set.
  839. 2.2.5  MAILCHECK
  840.  
  841. This variable specifies how often, in seconds, the BourneShell will
  842. check for new mail.  The default is 600 seconds.  If set to 0, it
  843. will check for new mail each time before it gives you a prompt.
  844.  
  845. 2.2.6  PATH
  846.  
  847. This BourneShell variable will describe the directories that will
  848. be searched looking for the program that you want to execute.  The
  849. BourneShell looks in several directories for a file that has the
  850. same name as the command that you entered.  The PATH variable
  851. controls this search path. Normally, the first directory searched
  852. is the current working directory.  If the program is not found,
  853. the search continues in the /bin and then the /usr/bin directory. 
  854. Generally, these directories contain executable programs.  If the
  855. program is not found in one of these directories, the BourneShell
  856. reports that the program can't be found (or executed).
  857.  
  858. The PATH variable lists the pathnames in the order in which the
  859. search will proceed.  The pathnames are separated by a colon (:).
  860. If nothing (null string) precedes the colon, that indicates to
  861. start the search at the current working directory.
  862.  
  863. Example:
  864. .................................................................
  865. . $PATH=:/user0/rharding/bin:/bin:/usr/bin                      .
  866. . $                                                             .
  867. .................................................................
  868.  
  869. This PATH variable indicates to start the search for the program
  870. at the current working directory, then look in the directory
  871. /user0/rharding/bin, then /bin, and finally /usr/bin.
  872.  
  873. If each user has a unique path specified, each user can execute a
  874. different program by giving the same command.  The search for the
  875. program stops when it is satisfied; thus, you can use the same name
  876. for your own programs as the standard UNIX utilities.  To do this,
  877. simply put your program in one of the first directories that the
  878. BourneShell searches.
  879. 2.2.7  PS1
  880.  
  881. This is the BourneShell prompt which lets you know that the shell
  882. is waiting for you to give it a command.  The default BourneShell
  883. prompt is a dollar sign ($).  The shell stores the prompt as a
  884. string variable in PS1.  When you change the value of this
  885. variable, the appearance of the prompt will change.  When you are
  886. working on several different machines, it might be useful to have
  887. the prompt be the name of the machine you are working on.
  888.  
  889. Sample Session:
  890.  
  891. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  892. ‡ $pwd                                                          ‡
  893. ‡ /user0/rharding                                               ‡
  894. ‡ $PS1='domax0: '                                               ‡
  895. ‡ domax0:                                                       ‡
  896. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  897.  
  898. Notice that prompt is now domax0:
  899.  
  900. 2.2.8  PS2
  901.  
  902. This variable is called the secondary prompt.  If the command is
  903. not completed on one line and must be continued on the next line,
  904. the prompt for that continued line is PS2.  The default is >. This
  905. prompt indicates that the BourneShell is expecting you to finish
  906. the previous command line.
  907.  
  908. Sample Session:
  909.  
  910. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  911. ‡ $echo 'demonstration of prompt string                         ‡
  912. ‡ >2'                                                           ‡
  913. ‡ demonstration of prompt string                                ‡
  914. ‡ 2                                                             ‡
  915. ‡ $PS2='Continue? '                                             ‡
  916. ‡ $echo 'demonstration of                                       ‡
  917. ‡ Continue? prompt string 2'                                    ‡
  918. ‡ demonstration of                                              ‡
  919. ‡ prompt string 2                                               ‡
  920. ‡ $                                                             ‡
  921. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  922.  
  923. Notice how the secondary prompt was changed to "Continue? ".
  924. 2.3  Read-Only User Variables
  925.  
  926. The contents of the user variables and the shell variables can be
  927. modified by the user.  It is possible to assign a new value to
  928. them.  The new value can be assigned from the dollar ($) prompt or
  929. from inside a BourneShell script.  Read-only variables are
  930. different.  The value of read-only variables can not be changed.
  931.  
  932. The variable must be initialized to some value; and then, by
  933. entering the following command, it can be made read only.
  934.  
  935.  
  936. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  937. ”  Command format:    readonly variable_name                    ”
  938. ”                                                               ”
  939. ”  variable_name = name of the variable to be made read only    ”
  940. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  941.  
  942. Sample Session:
  943.  
  944. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  945. ‡ $person=Kathleen                                              ‡
  946. ‡ $readonly person                                              ‡
  947. ‡ $echo $person                                                 ‡
  948. ‡ Kathleen                                                      ‡
  949. ‡ $person=Richard                                               ‡
  950. ‡ person: is read only                                          ‡
  951. ‡ $                                                             ‡
  952. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  953.  
  954. The readonly command given without any arguments will display a
  955. list of all the read-only variables.
  956.  
  957. Sample Session:
  958.  
  959. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  960. ‡ $person=Kathleen                                              ‡
  961. ‡ $readonly person                                              ‡
  962. ‡ $example=Richard                                              ‡
  963. ‡ $readonly example                                             ‡
  964. ‡ $readonly                                                     ‡
  965. ‡ readonly person                                               ‡
  966. ‡ readonly example                                              ‡
  967. ‡ $                                                             ‡
  968. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  969. 2.4  Read-Only Shell Variables
  970.  
  971. The read-only shell variables are similar to the read-only user
  972. variables; except the value of these variables is assigned by the
  973. shell, and the user CANNOT modify them.
  974.  
  975.  
  976. 2.4.1  Name of the Calling Program
  977.  
  978. The shell will store the name of the command you used to call a
  979. program in the variable named $0.
  980.  
  981. It has the number zero because it appears before the first argument
  982. on the command line.
  983.  
  984. Sample Session:
  985.  
  986. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  987. ‡ $cat name_ex                                                  ‡
  988. ‡ echo 'The name of the command used'                           ‡
  989. ‡ echo 'to execute this script was' $0                          ‡
  990. ‡ $name_ex                                                      ‡
  991. ‡ The name of the command used                                  ‡
  992. ‡ to execute this script was name_ex                            ‡
  993. ‡ $                                                             ‡
  994. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  995.  
  996. 2.4.2  Arguments
  997.  
  998. The BourneShell will store the first nine command line arguments
  999. in the variables named $1, $2, ..., $9.  These variables appear in
  1000. this section because you cannot change them using the equal sign. 
  1001. It is possible to modify them using the set command.
  1002.  
  1003. Sample Session:
  1004.  
  1005. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1006. ‡ $cat arg_ex                                                   ‡
  1007. ‡ echo 'The first five command line'                            ‡
  1008. ‡ echo 'arguments are' $1 $2 $3 $4 $5                           ‡
  1009. ‡ $arg_ex Richard Kathleen Douglas                              ‡
  1010. ‡ The first five command line                                   ‡
  1011. ‡ arguments are Richard Kathleen Douglas                        ‡
  1012. ‡ $                                                             ‡
  1013. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1014.  
  1015. The script arg_ex will display the first five command-line
  1016. arguments.  The variables representing $4 and $5 have a null value.
  1017.  
  1018. The BourneShell variable $* represents all of the command-line
  1019. arguments as shown in the following example.
  1020.  
  1021. Sample Session:
  1022.  
  1023. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1024. ‡ $cat display_all                                              ‡
  1025. ‡ echo $*                                                       ‡
  1026. ‡ $display_all Richard Kathleen Douglas                         ‡
  1027. ‡ Richard Kathleen Douglas                                      ‡
  1028. ‡ $                                                             ‡
  1029. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1030.  
  1031. The BourneShell variable $# contains the number of arguments on
  1032. the command line.  This is a string variable that represents a
  1033. decimal number.  You can use the expr utility to perform
  1034. calculations with that number and test to perform logical tests on
  1035. it.
  1036.  
  1037. Sample Session:
  1038.  
  1039. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1040. ‡ $cat num_args                                                 ‡
  1041. ‡ echo 'This script was called with'                            ‡
  1042. ‡ echo $# 'arguments'                                           ‡
  1043. ‡ $num_args Richard Kathleen Douglas                            ‡
  1044. ‡ This script was called with                                   ‡
  1045. ‡ 3 arguments                                                   ‡
  1046. ‡ $                                                             ‡
  1047. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1048. 2.4.3  Shift
  1049.  
  1050. The shift command promotes each of the command-line arguments. 
  1051. The second argument, represented by $2, is now the first argument,
  1052. represented by $1.  The third becomes the second and so on until
  1053. the last argument becomes the next to last.  You can access only
  1054. the first nine command-line arguments (as $1 through $9).  The
  1055. shift command gives you access to the tenth, and the first becomes
  1056. unavailable.  There is no "unshift" command that will return the
  1057. arguments that are no longer available.
  1058.  
  1059. Sample Session: 
  1060.  
  1061. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1062. ‡ $cat demo_shift                                               ‡
  1063. ‡ echo 'arg1='$1 '  arg2='$2 '   arg3='$3                       ‡
  1064. ‡ shift                                                         ‡
  1065. ‡ echo 'arg1='$1 '  arg2='$2 '   arg3='$3                       ‡
  1066. ‡ shift                                                         ‡
  1067. ‡ echo 'arg1='$1 '  arg2='$2 '   arg3='$3                       ‡
  1068. ‡ shift                                                         ‡
  1069. ‡ echo 'arg1='$1 '  arg2='$2 '   arg3='$3                       ‡
  1070. ‡ shift                                                         ‡
  1071. ‡ $demo_shift Richard Kathleen Douglas                          ‡
  1072. ‡ arg1=Richard  arg2=Kathleen  arg3=Douglas                     ‡
  1073. ‡ arg1=Kathleen arg2=Douglas   arg3=                            ‡
  1074. ‡ arg1=Douglas  arg2=          arg3=                            ‡
  1075. ‡ demo_shift: cannot shift                                      ‡
  1076. ‡ $                                                             ‡
  1077. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1078.  
  1079. The BourneShell will display an error message when the script
  1080. executes a shift command after it has run out of variables.
  1081. 2.4.4  Set
  1082.  
  1083.  
  1084. The Set command will display a list of all the variables that are
  1085. set when it has no arguments.
  1086.  
  1087. Sample Session:
  1088.  
  1089. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1090. ‡ $set                                                          ‡
  1091. ‡ HOME=/user0/teacher                                           ‡
  1092. ‡ IFS=                                                          ‡
  1093. ‡                                                               ‡
  1094. ‡ LOGNAME=richard                                               ‡
  1095. ‡ MAIL=/usr/mail/richard                                        ‡
  1096. ‡ MAILCHECK=600                                                 ‡
  1097. ‡ PATH=:/bin:/usr/bin                                           ‡
  1098. ‡ PS1=$                                                         ‡
  1099. ‡ PS2=>                                                         ‡
  1100. ‡ SHELL=/bin/sh                                                 ‡
  1101. ‡ TERM=vt100                                                    ‡
  1102. ‡ TZ=MST7MDT                                                    ‡
  1103. ‡ $                                                             ‡
  1104. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1105.  
  1106. When set is called with arguments, it sets the value of the
  1107. command-line arguments ($1-$n) to the arguments.  The example sets
  1108. the first three arguments.
  1109.  
  1110. Sample Session:
  1111.  
  1112. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1113. ‡ $cat set_ex                                                   ‡
  1114. ‡ set who really cares                                          ‡
  1115. ‡ echo $#: $*                                                   ‡
  1116. ‡ $set_ex                                                       ‡
  1117. ‡ 3: who really cares                                           ‡
  1118. ‡ $                                                             ‡
  1119. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1120. 2.4.5  expr
  1121.  
  1122. The expr command will perform arithmetic in the BourneShell.
  1123.  
  1124. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1125. ”   Command format:  expr expression                            ”
  1126. ”                                                               ”
  1127. ”   See Appendix C for a complete list of expressions           ”
  1128. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1129.  
  1130. The arguments are taken as an expression. After the evaluation has
  1131. taken place, the result is written to standard output.  The terms
  1132. of the expression must be separated by blanks.  Special characters
  1133. to the shell must be escaped.  Strings containing blanks or other
  1134. special characters must be quoted.
  1135.  
  1136. Sample Session:
  1137.  
  1138. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1139. ‡ $expr 7 + 8 + 10                                              ‡
  1140. ‡ 25                                                            ‡
  1141. ‡ $expr 10 - 8                                                  ‡
  1142. ‡ 2                                                             ‡
  1143. ‡ $expr 10 '*' 4                                                ‡
  1144. ‡ 40                                                            ‡
  1145. ‡ $expr 135 / 5                                                 ‡
  1146. ‡ 27                                                            ‡
  1147. ‡ $                                                             ‡
  1148. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1149.  
  1150. expr will also work with user defined variables as in the following
  1151. example:
  1152.  
  1153. Sample Session:
  1154.  
  1155. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1156. ‡ $cat data                                                     ‡
  1157. ‡ 8                                                             ‡
  1158. ‡ 15                                                            ‡
  1159. ‡ 25                                                            ‡
  1160. ‡ $cat express                                                  ‡
  1161. ‡ count=0                                                       ‡
  1162. ‡ tot=0                                                         ‡
  1163. ‡ for a in `cat data`                                           ‡
  1164. ‡ do                                                            ‡
  1165. ‡ tot=`expr $tot + $a`                                          ‡
  1166. ‡ count=`expr $count + 1`                                       ‡
  1167. ‡ done                                                          ‡
  1168. ‡ avg=`expr $tot / $count`                                      ‡
  1169. ‡ echo "The average is $avg"                                    ‡
  1170. ‡ $                                                             ‡
  1171. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1172. Let's execute the script "express" with tracing on so we can follow
  1173. the execution.
  1174.  
  1175. Sample Session:
  1176.  
  1177. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1178. ‡ $sh -x express                                                ‡
  1179. ‡ count=0                                                       ‡
  1180. ‡ tot=0                                                         ‡
  1181. ‡ + cat data                                                    ‡
  1182. ‡ + expr 0 + 8                                                  ‡
  1183. ‡ tot=8                                                         ‡
  1184. ‡ + expr 0 + 1                                                  ‡
  1185. ‡ count=1                                                       ‡
  1186. ‡ + expr 8 + 15                                                 ‡
  1187. ‡ tot=23                                                        ‡
  1188. ‡ + expr 1 + 1                                                  ‡
  1189. ‡ count=2                                                       ‡
  1190. ‡ + expr 23 + 25                                                ‡
  1191. ‡ tot=48                                                        ‡
  1192. ‡ + expr 2 + 1                                                  ‡
  1193. ‡ count=3                                                       ‡
  1194. ‡ + expr 48 / 3                                                 ‡
  1195. ‡ avg=16                                                        ‡
  1196. ‡ + echo The average is 16                                      ‡
  1197. ‡ The average is 16                                             ‡
  1198. ‡ $                                                             ‡
  1199. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1200.                                NOTES
  1201. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  1202.                                NOTES
  1203. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  1204. Workshop 2
  1205.  
  1206. This workshop will reinforce your understanding of the ideas
  1207. presented in Chapter 2. Login to the Multimax using the username
  1208. and password given to you by the instructor.  Each student is to
  1209. complete the entire workshop.
  1210.  
  1211. DESK EXERCISES 
  1212.  
  1213.      1.   Any series of non-blank characters can be assigned to a
  1214.           user variable.
  1215.  
  1216.                             True/False
  1217.  
  1218.  
  1219.  
  1220.      2.   How can you insert a space into a user variable?
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.      3.   What utility can be used to display the contents of a
  1227.           user variable to standard output?
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.      4.   The backslash (\) character is used to remove the special
  1234.           meaning of some characters.
  1235.  
  1236.                             True/False
  1237.  
  1238.  
  1239.  
  1240.  
  1241.      5.   What other character can be used to prevent the shell
  1242.           from doing the substitution?
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.      6.   Double quote marks will prevent the shell from making
  1249.           the substitution.
  1250.  
  1251.                             True/False
  1252.  
  1253.  
  1254.  
  1255.                      Continue on the next page
  1256.      7.   What do the following shell variables do?
  1257.  
  1258.  
  1259.           HOME
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.           IFS
  1266.  
  1267.  
  1268.  
  1269.  
  1270.           MAIL
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.           MAILPATH
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.           MAILCHECK
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.           PATH
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.           PS1
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.           PS2
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.                      Continue on the next page
  1308.      8.   What is the command to create a read-only user variable?
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.      9.   What is the read-only shell variable that represents the
  1316.           calling program?
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.      10.  What do $1,$2,...,$9 represent?
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.      11.  What BourneShell variable represents all of the command
  1331.           line arguments?
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.      12.  What does the shift command do?
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.      13.  What is displayed when you enter set with no arguments?
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.                      Continue on the next page
  1360. COMPUTER EXERCISES 
  1361.  
  1362.  
  1363.      14.  Login to the Multimax (domax1) using the username and
  1364.           password given to you by the instructor.
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.      15.  Create a subdirectory called sub_dir.
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.      16.  Modify your .profile to include the following:
  1377.  
  1378.  
  1379.           a) Change the home directory to sub_dir
  1380.  
  1381.           b) Set the internal-field separator to a comma
  1382.  
  1383.           c) Have mail messages saved into mail1.
  1384.  
  1385.           d) Set the PATH to look for programs in the following  
  1386.              directories:
  1387.  
  1388.                $HOME/bin
  1389.                /bin
  1390.                /usr/bin
  1391.  
  1392.           e) Change the prompt to reflect the name of the system
  1393.  
  1394.           f) Change the secondary prompt to 'More?'
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.      17.  Execute the .profile
  1401.           Enter $. .profile
  1402.  
  1403.  
  1404.  
  1405.  
  1406.      18.  Verify that the changes are correct. If you have extra
  1407.            time go to the next page.
  1408.  
  1409.  
  1410.  
  1411.                     Extra Mile on the next page
  1412. Extra Mile
  1413.  
  1414.  
  1415. Change the .profile file so the date/time and a list of all
  1416. users that are currently logged in will be displayed on your
  1417. monitor screen automatically when you login.
  1418.                                NOTES
  1419. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  1420. 3.  POSITIONAL PARAMETERS
  1421.  
  1422.  
  1423. A BourneShell script can also read in command-line arguments.  
  1424. The first argument is referred to as $1, the second is $2, and so
  1425. on.  Command-line arguments are referred to as positional
  1426. parameters.
  1427.  
  1428. Let's look at an example BourneShell script to see how these are
  1429. used.
  1430.  
  1431. Sample Session:
  1432.  
  1433. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1434. ‡ $cat neat_shell                                               ‡
  1435. ‡ echo $1 $2 $3                                                 ‡
  1436. ‡ echo $0 is the name of the shell script                       ‡
  1437. ‡ echo "There were $# arguments."                               ‡
  1438. ‡ echo $*                                                       ‡
  1439. ‡ $                                                             ‡
  1440. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1441.  
  1442. Insure that the BourneShell script is executable by issuing this
  1443. command:
  1444.  
  1445. Sample Session:
  1446.  
  1447. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1448. ‡    $chmod a+x neat_shell                                      ‡
  1449. ‡    $                                                          ‡
  1450. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1451.  
  1452. Now, if we type the name of the BourneShell script with no
  1453. arguments, we get the following results.
  1454.  
  1455. Sample Session:
  1456.  
  1457. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1458. ‡ $neat_shell                                                   ‡
  1459. ‡                                                               ‡
  1460. ‡ neat_shell is the name of the shell script                    ‡
  1461. ‡ There were 0 arguments.                                       ‡
  1462. ‡                                                               ‡
  1463. ‡ $                                                             ‡
  1464. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1465.  
  1466. In this sample session, there were no arguments given so none were
  1467. printed.  $0 is the positional parameter that refers to the name
  1468. of the script.  Since there were no arguments given with this
  1469. invocation of neat_shell, there were zero arguments listed.      
  1470.                
  1471. 3.1  Reading Input Into a Shell Variable
  1472.  
  1473. The BourneShell script can read user input from standard input.  
  1474. The read command will read one line from standard input and assign
  1475. the line to one or more variables.  The following example shows how
  1476. this works.
  1477.  
  1478. Sample Session:
  1479.  
  1480. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1481. ‡ $cat read_script                                              ‡
  1482. ‡ echo "Please enter a string of your choice"                   ‡
  1483. ‡ read a                                                        ‡
  1484. ‡ echo $a                                                       ‡
  1485. ‡ $                                                             ‡
  1486. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1487.  
  1488. This simple script will read one line from standard input
  1489. (keyboard) and assign it to the variable a.
  1490.  
  1491. Sample Session:
  1492.  
  1493. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1494. ‡ $read_script                                                  ‡
  1495. ‡ Please enter a string of your choice                          ‡
  1496. ‡ Here it is                                                    ‡
  1497. ‡ Here it is                                                    ‡
  1498. ‡ $                                                             ‡
  1499. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1500.  
  1501. The line read from standard input can also be assigned to several
  1502. variables as shown in the following example.
  1503.  
  1504.  
  1505. Sample Session:
  1506.                                                   
  1507. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1508. ‡ $cat reads                                                    ‡
  1509. ‡ echo "Please enter three strings"                             ‡
  1510. ‡ read a b c                                                    ‡
  1511. ‡ echo $a $b $c                                                 ‡
  1512. ‡ echo $c                                                       ‡
  1513. ‡ echo $b                                                       ‡
  1514. ‡ echo $a                                                       ‡
  1515. ‡ $                                                             ‡
  1516. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1517.  
  1518. This time, we will turn on the trace mechanism and follow the
  1519. execution of this BourneShell script.
  1520.  
  1521. Sample Session:
  1522.  
  1523. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1524. ‡ $sh -x reads                                                  ‡
  1525. ‡ + echo Please enter three strings                             ‡
  1526. ‡ Please enter three strings                                    ‡
  1527. ‡ + read a b c                                                  ‡
  1528. ‡ this is more than three strings                               ‡
  1529. ‡ + echo this is more than three strings                        ‡
  1530. ‡ this is more than three strings                               ‡
  1531. ‡ + echo more than three strings                                ‡
  1532. ‡ more than three strings                                       ‡
  1533. ‡ + echo is                                                     ‡
  1534. ‡ is                                                            ‡
  1535. ‡ + echo this                                                   ‡
  1536. ‡ this                                                          ‡
  1537. ‡ $                                                             ‡
  1538. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1539.  
  1540. It is interesting to note that the spaces separate the values for
  1541. the variables a,b, and c.  For example, the variable a was assigned
  1542. the string this, the variable b was assigned the string is, and the
  1543. remainder of the line was assigned to c (including the spaces).
  1544.  
  1545. Sample Session:
  1546.                                                   
  1547. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1548. ‡ $cat read_ex                                                  ‡
  1549. ‡ echo  'Enter line: \c'                                        ‡
  1550. ‡ read line                                                     ‡
  1551. ‡ echo "The line was: $line"                                    ‡
  1552. ‡ $                                                             ‡
  1553. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1554.                                                                  
  1555. In this example, the \c option will suppress the carriage return.
  1556. The single quote marks protect the backslash from being interpreted
  1557. by the shell.  Also notice that the double quote marks have no
  1558. effect on the substitution of the variable line.                 
  1559.             
  1560. Sample Session:
  1561.  
  1562. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1563. ‡ $read_ex                                                      ‡
  1564. ‡ Enter line: All's well that ends well                         ‡
  1565. ‡ The line was: All's well that ends well                       ‡
  1566. ‡ $                                                             ‡
  1567. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1568. 3.2  Command Substitution
  1569.  
  1570. You can execute a command by enclosing it within two grave accent
  1571. marks [these are sometimes called backquotes (`)].  The BourneShell
  1572. will replace the command and the grave marks with the output from
  1573. the command.
  1574.  
  1575. Sample Session:
  1576.  
  1577. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1578. ‡ $cat dir                                                      ‡
  1579. ‡ dir=`pwd`                                                     ‡
  1580. ‡ echo 'You are using the' $dir 'directory'                     ‡
  1581. ‡ $                                                             ‡
  1582. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1583.                                                                  
  1584. NOTE:     The grave marks lean to the left, and the apostrophes 
  1585.           lean to the right.  The grave marks enclose the pwd  
  1586.           command.                                              
  1587.                                                                  
  1588. Sample Session:
  1589.  
  1590. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1591. ‡ $dir                                                          ‡
  1592. ‡ You are using the /user0/rharding directory                   ‡
  1593. ‡ $                                                             ‡
  1594. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1595.  
  1596. The important thing to notice here is that the pwd command was
  1597. executed; and the output, /user0/rharding, was then assigned to
  1598. the variable dir.
  1599.  
  1600. It is not necessary to assign the output of a command to a variable
  1601. as shown in the previous example.  The command substitution can
  1602. occur directly as shown in the next example.
  1603.  
  1604. Sample Session:
  1605.  
  1606. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1607. ‡ $cat dir2                                                     ‡
  1608. ‡ echo 'You are using the' `pwd` 'directory'                    ‡
  1609. ‡ $dir2                                                         ‡
  1610. ‡ You are using the /user0/rharding directory                   ‡
  1611. ‡ $                                                             ‡
  1612. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1613. One final example will show a practical use of command
  1614. substitution.  This BourneShell script will use the date command
  1615. to provide the date in a useful format.
  1616.  
  1617. The normal output from the date command looks like the following.
  1618.  
  1619. Sample Session:
  1620.  
  1621. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1622. ‡ $date                                                         ‡
  1623. ‡ Wed Sep 12 18:02:05 MDT 1990                                  ‡
  1624. ‡ $                                                             ‡
  1625. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1626.  
  1627. Here's a BourneShell script that rearranges the output into a more
  1628. useable format.
  1629.  
  1630. Sample Session:
  1631.  
  1632. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1633. ‡ $cat dateset                                                  ‡
  1634. ‡ set `date`                                                    ‡
  1635. ‡ echo $*                                                       ‡
  1636. ‡ echo                                                          ‡
  1637. ‡ echo 'Argument 1:' $1                                         ‡
  1638. ‡ echo 'Argument 2:' $2                                         ‡
  1639. ‡ echo 'Argument 3:' $3                                         ‡
  1640. ‡ echo 'Argument 4:' $4                                         ‡
  1641. ‡ echo                                                          ‡
  1642. ‡ echo $2 $3, $6                                                ‡
  1643. ‡ $dateset                                                      ‡
  1644. ‡ Wed Sep 12 18:02:05 MDT 1990                                  ‡
  1645. ‡                                                               ‡
  1646. ‡ Argument 1: Wed                                               ‡
  1647. ‡ Argument 2: Sep                                               ‡
  1648. ‡ Argument 3: 12                                                ‡
  1649. ‡ Argument 4: 18:02:05                                          ‡
  1650. ‡                                                               ‡
  1651. ‡ Sep 12, 1990                                                  ‡
  1652. ‡ $                                                             ‡
  1653. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1654.  
  1655. The first command in the BourneShell script dateset uses the grave
  1656. accent marks to set the command-line argument variables to the
  1657. output of the date command.  The next commands show the first four
  1658. of these argument variables.  The final command displays the
  1659. arguments in a different order that could be useful in a report or
  1660. a letter.
  1661. 3.3  Comments in BourneShell Scripts
  1662.  
  1663.  
  1664. Comments can be inserted into the BourneShell script by beginning
  1665. each comment line with the pound symbol (#) or a colon (:).  All
  1666. characters after the comment character will be ignored by the
  1667. shell.  The only exception to this rule is that the first character
  1668. of the first line must not be a pound symbol; if the first
  1669. character is a pound sign, the BourneShell tries to execute the
  1670. script as if it was written in CShell syntax.
  1671.  
  1672. Sample Session:
  1673.  
  1674. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1675. ‡ $cat com_sub                                                  ‡
  1676. ‡   #   The first line sets your present working directory      ‡
  1677. ‡ #     to the variable 'directory'                             ‡
  1678. ‡ directory=`pwd`                                               ‡
  1679. ‡ #     The second line sets the date to the variable 'when'    ‡
  1680. ‡ when=`date`                                                   ‡
  1681. ‡ :     The third line will echo on the screen                  ‡
  1682. ‡ echo "You are in $directory on $when"                         ‡
  1683. ‡ :     You could have said echo :                              ‡
  1684. ‡ :        "You are in `pwd` on `date`"                         ‡
  1685. ‡ :     to have a one line program                              ‡
  1686. ‡ $                                                             ‡
  1687. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1688.                                                                
  1689. 3.4  BourneShell Environment - Exporting Variables
  1690.  
  1691. Within a process, you can declare, initialize, read, and modify
  1692. variables.  The variable is local to that process.  When a process
  1693. forks a child process, the parent process does not automatically
  1694. pass the value of the variable to the child process.
  1695.  
  1696. Here is an example of the variables not being exported.
  1697.  
  1698. Sample Session:
  1699.  
  1700. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1701. ‡ $cat no_export                                                ‡
  1702. ‡ car=mercedes       # set the variable                         ‡
  1703. ‡ echo $0 $car $$    # $0 = name of file executed               ‡
  1704. ‡                    # $car =value of variable car              ‡
  1705. ‡                    # $$ = PID number (process id)             ‡
  1706. ‡ inner              # execute another BourneShell script       ‡
  1707. ‡ echo $0 $car $$    # display same as above                    ‡
  1708. ‡ $cat inner                                                    ‡
  1709. ‡ echo $0 $car $$    # display variables for this process       ‡
  1710. ‡ $chmod a+x no_export                                          ‡
  1711. ‡ $chmod a+x inner                                              ‡
  1712. ‡ $no_export                                                    ‡
  1713. ‡ no_export mercedes 4790                                       ‡
  1714. ‡ inner 4792                                                    ‡
  1715. ‡ no_export mercedes 4790                                       ‡
  1716. ‡ $                                                             ‡
  1717. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1718.  
  1719. When no_export was executed, it, of course, assigned a value of
  1720. mercedes to the variable car and printed it out.  The call to inner
  1721. created a child process.  Its PID is 4792, while the parent PID is
  1722. 4790.  Notice, when inner tried to print the value of car, it
  1723. printed nothing.  The reason is because the value of car was not
  1724. passed by the parent.
  1725. Can the value be passed from parent to child process?  Yes, by
  1726. using the export command.  Let's look at an example.
  1727.  
  1728. Sample Session:
  1729.  
  1730. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1731. ‡ $cat export_it                                                ‡
  1732. ‡ car=mercedes                                                  ‡
  1733. ‡ export car                                                    ‡
  1734. ‡ echo $0 $car $$                                               ‡
  1735. ‡ inner1                                                        ‡
  1736. ‡ echo $0 $car $$                                               ‡
  1737. ‡ $cat inner1                                                   ‡
  1738. ‡ echo $0 $car $$                                               ‡
  1739. ‡ car=chevy                                                     ‡
  1740. ‡ echo $0 $car $$                                               ‡
  1741. ‡ $chmod a+x export_it                                          ‡
  1742. ‡ $chmod a+x inner1                                             ‡
  1743. ‡ $export_it                                                    ‡
  1744. ‡ export_it mercedes 4798                                       ‡
  1745. ‡ inner1 mercedes 4800                                          ‡
  1746. ‡ inner1 chevy 4800                                             ‡
  1747. ‡ export_it mercedes 4798                                       ‡
  1748. ‡ $                                                             ‡
  1749. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  1750.  
  1751. In the export_it BourneShell script, the variable car was
  1752. initialized to mercedes; and then it was exported.  This means that
  1753. the value of car is now available to a child process.  When inner1
  1754. prints out the value of car it has the value of mercedes.  This is
  1755. as we expect because the value of car was exported from the parent. 
  1756. The next line of inner1 changes the value of car to chevy.  This
  1757. is shown in the next line of the sample session.  The last line of
  1758. the session shows the return to the parent process and the value
  1759. is still mercedes.  How is this possible? 
  1760.  
  1761. Exporting variables is only valid from the parent to the child
  1762. process.  The child process cannot change the parent's variable.
  1763. Workshop 3
  1764.  
  1765. This workshop will reinforce your understanding of the ideas
  1766. presented in Chapter 3. Login to the Multimax using the username
  1767. and password given to you by the instructor.  Each student is to
  1768. complete the entire workshop.
  1769.  
  1770. DESK EXERCISES 
  1771.  
  1772.  
  1773.      1.   What is the positional parameter that represents the name
  1774.           of the command?
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.      2.   What positional parameter stands for the number of
  1781.           arguments on the command line?
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.      3.   What command will read one line from standard input and
  1788.           assign the value to a variable?
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.      4.   What character is used to indicate command substitution?
  1796.      
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.      5.   What are the two characters that indicate comments in
  1803.           BourneShell scripts? 
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.                      Continue on the next page
  1815.  
  1816.      6.   Why is it bad practice to put a pound sign (#) in the
  1817.           first character position of the first line of a
  1818.           BourneShell script?
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.      7.   Variables set by the parent process are automatically
  1825.           known to the child process.
  1826.  
  1827.                             True/False
  1828.  
  1829.  
  1830.  
  1831.  
  1832.      8.   What command will allow the value of a variable to be
  1833.           passed to a child process?
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.      9.   Can a child process change the value of the parents'
  1841.           variable?  Why?
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847. COMPUTER EXERCISES
  1848.  
  1849.      10.  Write a BourneShell script called "reverse_it" that has
  1850.           three strings as parameters and then display the strings
  1851.           in opposite order. Be sure to include appropriate
  1852.           comments.
  1853.  
  1854.           Hint: positional parameters 
  1855.  
  1856.  
  1857.      11.  Write a BourneShell script called "read_it" that does
  1858.           the same as question 10 but prompts the user to enter
  1859.           each string separately. How would you trace the execution
  1860.           of this script. Do it!
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.                     Continue on the next page.
  1867.      12.  Write a BourneShell script that uses the output of the
  1868.           "date" command and changes it
  1869.  
  1870.           from:
  1871.  
  1872.                Wed Sep 12  18:02:05 MDT 1990
  1873.  
  1874.           to:
  1875.  
  1876.                Sep 12, 1990  18:02:05
  1877.                                NOTES
  1878. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  1879. 4.  CONTROL CONSTRUCTS:
  1880.  
  1881.  
  1882. The BourneShell control constructs can alter the flow of control
  1883. within the script.  The BourneShell provides simple two-way branch
  1884. if statements and multiple-branch case statements, plus for, while,
  1885. and until statements.
  1886.  
  1887.  
  1888. In discussing these control structures, the BourneShell keywords
  1889. will be in bold type and the normal type are the user supplied
  1890. items to cause the desired effect in command format boxes.
  1891. 4.1  Types of Tests Used with Control Constructs:
  1892.  
  1893.  
  1894. The test utility evaluates expressions and returns a condition
  1895. indicating whether or not the expression is true (equal to zero)
  1896. or false (not equal to zero).  There are no options with this
  1897. utility.  The format for this utility is as follows:
  1898.                     
  1899. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1900. ”  Command Format:  test expression                             ”
  1901. ”                                                               ”
  1902. ”  expression - composed of constants, variables, and           ”
  1903. ”               operators                                       ”
  1904. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1905.  
  1906.  
  1907. Expressions will be looked at in greater detail later with some
  1908. examples.  There are a few items that need to be mentioned that
  1909. apply to expressions.  Expressions can contain one or more
  1910. evaluation criteria that test will evaluate.  A -a that separates
  1911. two criteria is a logical AND operator.  In this case, both
  1912. criteria must evaluate to true in order for test to return a value
  1913. of true.  The -o is the logical OR operator.  When this operator
  1914. separates two criteria, one or the other (or both) must be true for
  1915. test to return a true condition.
  1916.  
  1917. You can negate any criterion by preceding it with an exclamation
  1918. mark (!).  Parentheses can be used to group criteria.  If there
  1919. are no parentheses, the -a (logical AND operator) takes precedence
  1920. over the -o (logical OR operator).  The test utility will evaluate
  1921. operators of equal precedence from left to right.
  1922.  
  1923. Within the expression itself, you must put special characters, such
  1924. as parentheses, in quote marks so the BourneShell will not evaluate
  1925. them but will pass them to test.
  1926.  
  1927. Since each element (evaluation criterion, string, or variable) in
  1928. an expression is a separate argument, each must be separated by a
  1929. space.
  1930.  
  1931. The test utility will work from the command line but it is more
  1932. often used in a script to test input or verify access to a file.
  1933.  
  1934. Another way to do the test evaluation is to surround the expression
  1935. with left and right brackets. A space character must appear after
  1936. the left bracket and before the right bracket.
  1937.  
  1938.  
  1939.   test expression    =   [ expression ]
  1940.  
  1941.  
  1942.  
  1943. 4.2  Test on Numeric Values
  1944.  
  1945. Test expressions can be in many different forms. The expressions
  1946. can appear as a set of evaluation criteria. The general form for
  1947. testing numeric values is:
  1948.  
  1949. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  1950. ”          int1 op int2                                         ”
  1951. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  1952.  
  1953. This criterion is true if the integer int1 has the specified
  1954. algebraic relationship to integer int2.
  1955.  
  1956. The valid operators (op) are:
  1957.  
  1958.      -eq       equal
  1959.  
  1960.      -ne       not equal
  1961.  
  1962.      -gt       greater than
  1963.  
  1964.      -lt       less than
  1965.  
  1966.      -ge       greater than or equal
  1967.  
  1968.      -le       less than or equal
  1969.  
  1970. 4.3  Test on Character Strings
  1971.  
  1972. The evaluation criterion for character strings is similar to
  1973. numeric comparisons.  The general form is:
  1974.  
  1975.      string1 op string2
  1976.  
  1977. The operators (op) are:
  1978.  
  1979.      string1 = string2        true if string1 and string 2 are
  1980.                               equal
  1981.  
  1982.      string1 != string2       true if string1 and string2 are not
  1983.                               equal
  1984.  
  1985.      string1                  true if string1 is not the null
  1986.                               string
  1987. Sample Session:
  1988.  
  1989. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  1990. ‡ $ cat test_string                                             ‡
  1991. ‡ number=1                                                      ‡
  1992. ‡ numero=0001                                                   ‡
  1993. ‡ if test $number = $numero                                     ‡
  1994. ‡ then echo "String vals for $number and $numero are ="         ‡
  1995. ‡ else echo "String vals for $number and $numero not ="         ‡
  1996. ‡ fi                                                            ‡
  1997. ‡ if test $number -eq $numero                                   ‡
  1998. ‡ then echo "Numeric vals for $number and $numero are ="        ‡
  1999. ‡ else echo "Numeric vals for $number and $numero not ="        ‡
  2000. ‡ fi                                                            ‡
  2001. ‡ $chmod 755 test_string                                        ‡
  2002. ‡ $sh -x test_string                                            ‡
  2003. ‡ number=1                                                      ‡
  2004. ‡ numero=0001                                                   ‡
  2005. ‡ + test 1 = 0001                                               ‡
  2006. ‡ + echo String vals for 1 and 0001 not =                       ‡
  2007. ‡ String vals for 1 and 0001 not =                              ‡
  2008. ‡ + test 1 -eq 0001                                             ‡
  2009. ‡ + echo Numeric vals for 1 and 0001 are =                      ‡
  2010. ‡ Numeric  vals for 1 and 0001 are =                            ‡
  2011. ‡ $test_string                                                  ‡
  2012. ‡ String vals for 1 and 0001 not =                              ‡
  2013. ‡ Numeric vals for 1 and 0001 are =                             ‡
  2014. ‡ $                                                             ‡
  2015. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2016. 4.4  Test on File Types                                       
  2017.  
  2018.  
  2019. The test utility can be used to determine information about file
  2020. types.  All of the criterion can be found in Appendix B.  A few of
  2021. them are listed here:
  2022.  
  2023.      -r filename         true if filename exists and is readable
  2024.  
  2025.      -w filename         true if filename exists and is writable
  2026.  
  2027.      -x filename         true if filename exists and is executable
  2028.  
  2029.      -f filename         true if filename exists and it is a plain
  2030.                          file
  2031.  
  2032.      -d filename         true if filename exists and it is a
  2033.                          directory.
  2034.  
  2035.      -s filename         true if filename exits and it contains
  2036.                          information (has a size greater than 0
  2037.                          bytes)
  2038.  
  2039.  
  2040. Example:
  2041. .................................................................
  2042. . $test -d new_dir                                              .
  2043. .................................................................
  2044.  
  2045. If new_dir is a directory, this criterion will evaluate to true. 
  2046. If it does not exist, then it will be false.
  2047. 4.5  if then
  2048.  
  2049. The format for this construct is:
  2050.  
  2051. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2052. ”  Command Format:  if expression                               ”
  2053. ”                        then  commands                         ”
  2054. ”                   fi                                          ”
  2055. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2056.  
  2057. The if statement evaluates the expression and then returns control
  2058. based on this status.  The fi statement marks the end of the if,
  2059. notice that fi is if spelled backward.
  2060.  
  2061. The if statement executes the statements immediately following it
  2062. if the expression returns a true status. If the return status is
  2063. false, control will transfer to the statement following the fi.
  2064. Sample Session:
  2065.  
  2066. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2067. ‡ $cat check_args                                               ‡
  2068. ‡ if (test $# = 0)                                              ‡
  2069. ‡      then echo 'Please supply at least 1 argument'            ‡
  2070. ‡      exit                                                     ‡
  2071. ‡ fi                                                            ‡
  2072. ‡ echo 'Program is running'                                     ‡
  2073. ‡ $                                                             ‡
  2074. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2075.  
  2076. This little script will check to insure that you are giving at
  2077. least one argument.  If none are given it will display the error
  2078. message and exit.  If one or more arguments are given it will
  2079. display "Program is running" and run the rest of the script, if
  2080. any.
  2081.  
  2082. Sample Session:
  2083.  
  2084. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2085. ‡ $check_args                                                   ‡
  2086. ‡ Please supply at least 1 argument                             ‡
  2087. ‡ $check_args xyz                                               ‡
  2088. ‡ Program is running                                            ‡
  2089. ‡ $                                                             ‡
  2090. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2091. 4.6  if then else
  2092.  
  2093.  
  2094. The format for this construct is:
  2095.  
  2096. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2097. ”  Command Format:  if expression                               ”
  2098. ”                        then commands                          ”
  2099. ”                        else commands                          ”
  2100. ”                   fi                                          ”
  2101. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2102.  
  2103. The else part of this structure makes the single-branch if
  2104. statement into a two-way branch.  If the expression returns a true
  2105. status, the commands between the then and the else statement will
  2106. be executed.  After these have been executed, control will start
  2107. again at the statement after the fi.
  2108.  
  2109. If the expression returns false, the commands following the else
  2110. statement will be executed.
  2111. Sample Session:
  2112.  
  2113. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2114. ‡ $cat test_string                                              ‡
  2115. ‡ number=1                                                      ‡
  2116. ‡ numero=0001                                                   ‡
  2117. ‡ if test $number = $numero                                     ‡
  2118. ‡ then echo "String values of $number and $numero are equal"    ‡
  2119. ‡ else echo "String values of $number and $numero not equal"    ‡
  2120. ‡ fi                                                            ‡
  2121. ‡ if test $number -eq $numero                                   ‡
  2122. ‡ then echo "Numeric values of $number and $numero are equal"   ‡
  2123. ‡ else echo "Numeric values of $number and $numero not equal"   ‡
  2124. ‡ fi                                                            ‡
  2125. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2126.                                                                  
  2127.  
  2128. Let's follow the execution of this script with tracing.
  2129.  
  2130. Sample Session:
  2131.  
  2132. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2133. ‡ $sh -x test_string                                            ‡
  2134. ‡ number=1                                                      ‡
  2135. ‡ numero=0001                                                   ‡
  2136. ‡ + test 1 = 0001                                               ‡
  2137. ‡ + echo String values of 1 and 0001 are not equal              ‡
  2138. ‡ String values of 1 and 0001 are not equal                     ‡
  2139. ‡ + test 1 -eq 0001                                             ‡
  2140. ‡ + echo Numeric values of 1 and 0001 are equal                 ‡
  2141. ‡ Numeric values of 1 and 0001 are equal                        ‡
  2142. ‡ $chmod a+x test_string                                        ‡
  2143. ‡ $test_string                                                  ‡
  2144. ‡ String values of 1 and 0001 are not equal                     ‡
  2145. ‡ Numeric values of 1 and 0001 are equal                        ‡
  2146. ‡ $                                                             ‡
  2147. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2148.  4.7  if then elif
  2149.  
  2150.  
  2151. The format for this construct is:
  2152.  
  2153. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2154. ”  Command Format:  if expression                               ”
  2155. ”                        then commands                          ”
  2156. ”                     elif expression                           ”
  2157. ”                            then commands                      ”
  2158. ”                            else commands                      ”
  2159. ”                   fi                                          ”
  2160. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2161.  
  2162. The elif construct combines the else and if statements and allows
  2163. you to construct a nested set of if then else structures.
  2164. 4.8  for
  2165.  
  2166.  
  2167. The format for this construct is:
  2168.  
  2169. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2170. ”  Command Format:  for loop-index in argument-list             ”
  2171. ”                        do                                     ”
  2172. ”                        commands                               ”
  2173. ”                        done                                   ”
  2174. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2175.  
  2176. This structure will assign the value of the first item in the
  2177. argument list to the loop index and executes the commands between
  2178. the do and done statements.  The do and done statements indicate
  2179. the beginning and end of the for loop.
  2180.  
  2181. After the structure passes control to the done statement, it
  2182. assigns the value of the second item in the argument list to the
  2183. loop index and repeats the commands.  The structure will repeat
  2184. the commands between the do and done statements once for each
  2185. argument in the argument list.  When the argument list has been
  2186. exhausted, control passes to the statement following the done.
  2187. Sample Session:
  2188.  
  2189. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2190. ‡ $cat find_henry1                                              ‡
  2191. ‡ for x in project1 project2 project3                           ‡
  2192. ‡ do                                                            ‡
  2193. ‡ grep henry $x                                                 ‡
  2194. ‡ done                                                          ‡
  2195. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2196.  
  2197. Sample Session:
  2198.  
  2199. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2200. ‡ $head project?                                                ‡
  2201. ‡ ==> project1 <==                                              ‡
  2202. ‡ henry                                                         ‡
  2203. ‡ joe                                                           ‡
  2204. ‡ mike                                                          ‡
  2205. ‡ sue                                                           ‡
  2206. ‡                                                               ‡
  2207. ‡ ==> project2 <==                                              ‡
  2208. ‡ joe                                                           ‡
  2209. ‡ mike                                                          ‡
  2210. ‡ sue                                                           ‡
  2211. ‡                                                               ‡
  2212. ‡ ==> project3 <==                                              ‡
  2213. ‡ joe                                                           ‡
  2214. ‡ mike                                                          ‡
  2215. ‡ sue                                                           ‡
  2216. ‡ henry                                                         ‡
  2217. ‡                                                               ‡
  2218. ‡ ==> project4 <==                                              ‡
  2219. ‡ joe                                                           ‡
  2220. ‡ mike                                                          ‡
  2221. ‡                                                               ‡
  2222. ‡ $find_henry                                                   ‡
  2223. ‡ henry                                                         ‡
  2224. ‡ henry                                                         ‡
  2225. ‡ $                                                             ‡
  2226. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2227.  
  2228.  
  2229. Each file in the argument list was searched for the string, henry.
  2230. When a match was found, the string was printed.
  2231. 4.9  while
  2232.  
  2233.  
  2234. The format for this construct is:
  2235.  
  2236. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2237. ”  Command Format:  while expression                            ”
  2238. ”                        do                                     ”
  2239. ”                        commands                               ”
  2240. ”                        done                                   ”
  2241. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2242. As long as the expression returns a true exit status, the structure
  2243. continues to execute the commands between the do and the done
  2244. statement.  Before each loop through the commands, the structure
  2245. executes the expression.  When the exit status of the expression
  2246. is false (non-zero), control is passed to the statement following
  2247. the done statement.
  2248.  
  2249. The commands to be executed must change the expression test or an
  2250. infinite loop can result.
  2251. 4.10  until
  2252.  
  2253.  
  2254. The format for this construct is:
  2255.  
  2256. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2257. ”  Command Format:  until expression                            ”
  2258. ”                        do                                     ”
  2259. ”                        commands                               ”
  2260. ”                        done                                   ”
  2261. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2262.  
  2263. The until and while structures are very similar.  The only
  2264. difference is that the test is at the top of the loop.  The until
  2265. structure will continue to loop until the expression returns true
  2266. or a nonerror condition.  The while loop will continue as long as
  2267. a true or nonerror condition is returned.
  2268.  
  2269. The commands to be executed must change the expression test or an
  2270. infinite loop can result.
  2271. Sample Session:
  2272.  
  2273. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2274. ‡ $cat until_ex                                                 ‡
  2275. ‡ secretname='jenny'                                            ‡
  2276. ‡ name='noname'                                                 ‡
  2277. ‡ echo 'Try to guess the secret name!'                          ‡
  2278. ‡ echo                                                          ‡
  2279. ‡ until (test "$name" = "$secretname")                          ‡
  2280. ‡     do                                                        ‡
  2281. ‡     echo 'Your guess:  \c'                                    ‡
  2282. ‡     read name                                                 ‡
  2283. ‡     done                                                      ‡
  2284. ‡ echo 'You did it!'                                            ‡
  2285. ‡ $                                                             ‡
  2286. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2287.  
  2288. The until loop will continue until name is equal to the secret
  2289. name.
  2290.  
  2291.  
  2292. Sample Session:
  2293.  
  2294. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2295. ‡ $chmod a+x until_ex                                           ‡
  2296. ‡ $until_ex                                                     ‡
  2297. ‡ Try to guess the secret name!                                 ‡
  2298. ‡                                                               ‡
  2299. ‡ Your guess: gaylan                                            ‡
  2300. ‡ Your guess: art                                               ‡
  2301. ‡ Your guess: richard                                           ‡
  2302. ‡ Your guess: jenny                                             ‡
  2303. ‡ You did it!                                                   ‡
  2304. ‡ $                                                             ‡
  2305. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2306. 4.11  case
  2307.  
  2308.  
  2309. The format for this construct is:
  2310.  
  2311. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2312. ”  Command Format:  case test-string in                         ”
  2313. ”                        pattern-1 ) commands-1 ;;              ”
  2314. ”                        pattern-2 ) commands-2 ;;              ”
  2315. ”                        pattern-3 ) commands-3 ;;              ”
  2316. ”                        .                                      ”
  2317. ”                        .                                      ”
  2318. ”                        .                                      ”
  2319. ”                        *)          commands   ;;              ”
  2320. ”                   esac                                        ”
  2321. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2322.  
  2323. The case structure allows a multiple-branch decision mechanism.
  2324. The path that is taken depends on a match between the test-string
  2325. and one of the patterns.
  2326. Sample Session:
  2327.                                                   
  2328. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2329. ‡ $cat case_ex                                                  ‡
  2330. ‡ echo 'Enter A, B, or C: \c'                                   ‡
  2331. ‡ read letter                                                   ‡
  2332. ‡ case $letter in                                               ‡
  2333. ‡    A) echo 'You entered A' ;;                                 ‡
  2334. ‡    B) echo 'You entered B' ;;                                 ‡
  2335. ‡    C) echo 'You entered C' ;;                                 ‡
  2336. ‡    *) echo 'You did not enter A, B, or C' ;;                  ‡
  2337. ‡ esac                                                          ‡
  2338. ‡ $chmod a+x case_ex                                            ‡
  2339. ‡ $case_ex                                                      ‡
  2340. ‡ Enter A, B, or C: B                                           ‡
  2341. ‡ You entered B                                                 ‡
  2342. ‡ $case_ex                                                      ‡
  2343. ‡ Enter A, B, or C: b                                           ‡
  2344. ‡ You did not enter A, B, or C                                  ‡
  2345. ‡ $                                                             ‡
  2346. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2347.  
  2348. This example uses the value of a character that the user entered
  2349. as the test string.  The value is represented by the variable
  2350. letter.  If letter has the value of A, the structure will execute
  2351. the command following A.  If letter has a value of B or C, then
  2352. the appropriate commands will be executed.  The asterisk indicates
  2353. any string of characters; and it, therefore, functions as a
  2354. catchall for a no-match condition.  The lowercase b in the second
  2355. sample session is an example of a no match condition.
  2356.                                NOTES
  2357. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  2358.                                NOTES
  2359. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  2360. Workshop 4
  2361.  
  2362. This workshop will reinforce your understanding of the ideas
  2363. presented in Chapter 4. Login to the Multimax using the username
  2364. and password given to you by the instructor.  Each student is to
  2365. complete the entire workshop.
  2366.  
  2367. DESK EXERCISES 
  2368.  
  2369.  
  2370.      1.   Which utility will evaluate an expression and then return
  2371.           a condition indicating whether or not the expression is
  2372.           true (equal to zero) or false (not equal to zero)?
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.      2.   What are the operators for character string comparisons?
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.                      Continue on the next page
  2391. COMPUTER EXERCISES 
  2392.  
  2393.  
  2394.      3.   Use the "if then" construct to write a BourneShell script
  2395.           that will check for at least two parameters being present
  2396.           on the command line. Output an appropriate error message.
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.      4.   Write a BourneShell script using the "if then else"
  2406.           construct that will check for equality of two strings
  2407.           that are supplied as parameters to the script. Output a
  2408.           message stating if the strings are equal or not equal.
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.      5.   Write a BourneShell script using the "if then elif"
  2417.           construct that will check two numbers, input as
  2418.           parameters, and tell if the first parameter is greater
  2419.           than, equal to, or less than the second number. Output
  2420.           appropriate error messages.
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.      6.   Write a BourneShell script using the "for" construct that
  2428.           has a loop index called "fruit" and an argument list as
  2429.           follows: apples oranges bananas pears. Echo the name of
  2430.           each argument to the monitor screen and when the last
  2431.           argument is listed output an appropriate message.
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.                      Continue on the next page
  2443.  
  2444.      7.   Write a BourneShell script using the "while" construct
  2445.           that will add all the numbers between 0 and 9 and display
  2446.           the result. The sum of the digits 0 through 9 is 45.
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.       8.  Write a BourneShell script using the "until" construct
  2457.           similar to the example in the manual except compare
  2458.           numbers instead of strings.
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.       9.  Write a BourneShell script using the "case" statement
  2470.           that will ask you to enter the day of the week and then
  2471.           echo that day to the monitor screen. Be sure to include
  2472.           an appropriate message if you enter in a string other
  2473.           than a valid day of the week.
  2474.  
  2475.  
  2476.  
  2477.  
  2478. EXTRA MILE
  2479.  
  2480.  
  2481.      10.  Write a BourneShell script called "dir_num" that will
  2482.           test all of the files in the current directory and print
  2483.           all the files that prove to be a directory.
  2484.                                NOTES
  2485. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  2486. 5. COMPILING PROGRAMS IN UNIX
  2487.  
  2488. This chapter will examine compiling source code programs in three
  2489. high level languages "C", FORTRAN, and COBOL. The second part of
  2490. the chapter will look at the archive and library maintainer. The
  2491. archive allows you to create a library of object modules. These
  2492. files are used by the link editor.
  2493.  
  2494. 5.1  "C": Sample Program with a Main and Two Functions in One    
  2495.       File
  2496.  
  2497. Based on the command line options, cc compiles, assembles, and load
  2498. C language source code programs.  It can also assemble and load
  2499. assembly language source programs or merely load object programs.
  2500.  
  2501. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2502. ”  Command Format:  cc [options] file-list                      ”
  2503. ”                                                               ”
  2504. ”  (See Appendix E for a complete list of options)              ”
  2505. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2506.  
  2507. When using the cc utility, the following conventions are observed:
  2508.  
  2509.      1.   A filename with the extension of .c indicates a C
  2510.           language source program.
  2511.  
  2512.      2.   A filename with an extension of .s indicates an assembly
  2513.           language source program.
  2514.  
  2515.      3.   A filename with an extension of .o indicates an object
  2516.           program.
  2517.  
  2518.  
  2519. The cc utility will take its input from the file or files you
  2520. specify on the command line.  Unless you use the -o option, it will
  2521. store the executable program in a file called a.out.
  2522. Sample C Language Source Code Program:
  2523.                            
  2524. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2525. ‡ $cat hello.c                                                  ‡
  2526. ‡ main ()                                                       ‡
  2527. ‡ {                                                             ‡
  2528. ‡      printf ("Hello from main!\n\n");                         ‡
  2529. ‡      printf ("Calling function1!\n\n");                       ‡
  2530. ‡      funct1();                                                ‡
  2531. ‡      printf ("\t Back from function1!\n\n");                  ‡
  2532. ‡      printf ("Calling function2!\n\n");                       ‡
  2533. ‡      funct2();                                                ‡
  2534. ‡      printf ("\t Back from funct2!\n\n");                     ‡
  2535. ‡      printf ("That's all!\n\n");                              ‡
  2536. ‡ }                                                             ‡
  2537. ‡ funct1()                                                      ‡
  2538. ‡ {                                                             ‡
  2539. ‡      printf ("\t\t Hello from function1!\n\n);                ‡
  2540. ‡ }                                                             ‡
  2541. ‡ funct2()                                                      ‡
  2542. ‡ {                                                             ‡
  2543. ‡      printf ("\t\t Hello from function2!\n\n);                ‡
  2544. ‡ }                                                             ‡
  2545. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2546.  
  2547. 5.2  "C": Compiling a Program
  2548.  
  2549.  
  2550. To compile the previous example program into an executable module,
  2551. enter the following command at the command line.
  2552.  
  2553. Sample Session:
  2554.  
  2555. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2556. ‡ $cc hello.c                                                   ‡
  2557. ‡ $                                                             ‡
  2558. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2559.  
  2560. Without any options, cc accepts C source code and assembly language
  2561. programs that follow the conventions outlined above.  It will
  2562. compile, assemble, and load these programs to produce an executable
  2563. called a.out.  The cc utility puts the object code in files with
  2564. the same base filename (everything before the period) as the source
  2565. but with a filename extension of .o .  The a.out stands for
  2566. assembly output.  This is the default.
  2567.  
  2568. Sample Session:
  2569.  
  2570. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2571. ‡ $cc hello.c                                                   ‡
  2572. ‡ $a.out                                                        ‡
  2573. ‡ Hello from main!                                              ‡
  2574. ‡                                                               ‡
  2575. ‡ Calling function1!                                            ‡
  2576. ‡                                                               ‡
  2577. ‡                Hello from function1!                          ‡
  2578. ‡                                                               ‡
  2579. ‡           Back from function1!                                ‡
  2580. ‡                                                               ‡
  2581. ‡ Calling function2!                                            ‡
  2582. ‡                                                               ‡
  2583. ‡                Hello from function2!                          ‡
  2584. ‡                                                               ‡
  2585. ‡           Back from function2!                                ‡
  2586. ‡                                                               ‡
  2587. ‡ That's all!                                                   ‡
  2588. ‡ $                                                             ‡
  2589. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2590.  
  2591. NOTE:     The a.out file that was created by the cc utility has
  2592.           the following permissions:
  2593.  
  2594.           user - read, write, and execute 
  2595.           group - read and execute
  2596.           other - read and execute
  2597.  
  2598.  
  2599. It is not necessary for you to change the permissions using the
  2600. chmod command because the cc utility set the execute permissions
  2601. for you.
  2602. 5.3  "C": Renaming the Executable Module
  2603.  
  2604.  
  2605. You can rename the executable module using the mv command.  The
  2606. file permissions will be the same as before the file is renamed.
  2607.  
  2608. Sample Session:
  2609.  
  2610. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2611. ‡ $mv a.out hello                                               ‡
  2612. ‡ $hello                                                        ‡
  2613. ‡ Hello from main!                                              ‡
  2614. ‡                                                               ‡
  2615. ‡ Calling function1!                                            ‡
  2616. ‡                                                               ‡
  2617. ‡                Hello from function1!                          ‡
  2618. ‡                                                               ‡
  2619. ‡           Back from function1!                                ‡
  2620. ‡                                                               ‡
  2621. ‡ Calling function2!                                            ‡
  2622. ‡                                                               ‡
  2623. ‡                Hello from function2!                          ‡
  2624. ‡                                                               ‡
  2625. ‡           Back from function2!                                ‡
  2626. ‡                                                               ‡
  2627. ‡ That's all!                                                   ‡
  2628. ‡ $                                                             ‡
  2629. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2630. 5.4  "C": Giving a Name to the Output File
  2631.  
  2632.  
  2633. It is possible to have the output sent to a file you specify
  2634. instead of a.out by using the following command:
  2635.  
  2636. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2637. ”  Command Format:  cc -o output source                         ”
  2638. ”                                                               ”
  2639. ”  output - the name of the executable file                     ”
  2640. ”                                                               ”
  2641. ”  source - the name of the C source code file                  ”
  2642. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2643.                                                                 
  2644. The -o option tells cc to tell the link editor to use the specified
  2645. name for the output instead of the default a.out.
  2646.  
  2647. NOTE:     It is not necessary for the -o option to appear after the
  2648.           cc command.  The filename that appears after the -o is
  2649.           the name of the output file.  For example, cc source -
  2650.           o output is the same as cc -o output source.
  2651.  
  2652. Sample Session:
  2653.  
  2654. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2655. ‡ $cc -o hello hello.c                                          ‡
  2656. ‡ $hello                                                        ‡
  2657. ‡ Hello from main!                                              ‡
  2658. ‡ Calling function1!                                            ‡
  2659. ‡                                                               ‡
  2660. ‡                Hello from function1!                          ‡
  2661. ‡                                                               ‡
  2662. ‡           Back from function1!                                ‡
  2663. ‡                                                               ‡
  2664. ‡ Calling function2!                                            ‡
  2665. ‡                                                               ‡
  2666. ‡                Hello from function2!                          ‡
  2667. ‡                                                               ‡
  2668. ‡           Back from function2!                                ‡
  2669. ‡                                                               ‡
  2670. ‡ That's all!                                                   ‡
  2671. ‡ $                                                             ‡
  2672. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2673. 5.5  "C": Producing an Assembly Listing
  2674.  
  2675.  
  2676. This option causes cc to compile C programs and leave the
  2677. corresponding assembly language source programs in a file with
  2678. filename extensions of .s.
  2679.  
  2680. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2681. ”  Command Format:  cc -S hello.c                               ”
  2682. ”                                                               ”
  2683. ”  -S = Compile only                                            ”
  2684. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2685.  
  2686. Sample Session:
  2687.  
  2688. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2689. ‡ $cc -S  hello.c                                               ‡
  2690. ‡ $ls -C                                                        ‡
  2691. ‡ example.f    hello     hex.c     octal.c                      ‡
  2692. ‡ hello.c      hello.s   multiply.c                             ‡
  2693. ‡ $                                                             ‡
  2694. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2695. 5.6  "C": Main and Two Functions in Three Separate Source Files
  2696.  
  2697.  
  2698. This is the same C program that we have seen before, except it is
  2699. now in three files rather than one as before.  The three files are
  2700. main.c, funct1.c, and funct2.c.
  2701.  
  2702.  
  2703. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2704. ‡ $cat main.c                                                   ‡
  2705. ‡ main ()                                                       ‡
  2706. ‡ {                                                             ‡
  2707. ‡      printf ("Hello from main!\n\n");                         ‡
  2708. ‡      printf ("Calling function1!\n\n");                       ‡
  2709. ‡      funct1();                                                ‡
  2710. ‡      printf ("\t Back from function1!\n\n");                  ‡
  2711. ‡      printf ("Calling function2!\n\n");                       ‡
  2712. ‡      funct2();                                                ‡
  2713. ‡      printf ("\t Back from funct2!\n\n");                     ‡
  2714. ‡      printf ("That's all!\n\n");                              ‡
  2715. ‡ }                                                             ‡
  2716. ‡ $cat funct1.c                                                 ‡
  2717. ‡ funct1()                                                      ‡
  2718. ‡ {                                                             ‡
  2719. ‡      printf ("\t\t Hello from function1!\n\n);                ‡
  2720. ‡ }                                                             ‡
  2721. ‡ $cat funct2.c                                                 ‡
  2722. ‡ funct2()                                                      ‡
  2723. ‡ {                                                             ‡
  2724. ‡      printf ("\t\t Hello from function2!\n\n);                ‡
  2725. ‡ }                                                             ‡
  2726. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2727. 5.7  "C": Compiling but Not Producing an Executable Module
  2728.  
  2729.  
  2730. Using the previous program, the following command will compile but
  2731. not produce an executable module.
  2732.  
  2733. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2734. ”     Command Format:     cc -c main.c funct1.c funct2.c        ”
  2735. ”                                                               ”
  2736. ”     -c = Compile, but do not load object files.  This option  ”
  2737. ”          causes cc to compile and/or assemble source code     ”
  2738. ”          programs and leave the corresponding object programs ”
  2739. ”          in files with filename extensions of .o.             ”
  2740. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2741.  
  2742. Sample Session:
  2743.  
  2744. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2745. ‡ $cc -c main.c funct1.c funct2.c                               ‡
  2746. ‡ main.c:                                                       ‡
  2747. ‡ funct1.c:                                                     ‡
  2748. ‡ funct2.c:                                                     ‡
  2749. ‡ $ls a.out                                                     ‡
  2750. ‡ a.out not found                                               ‡
  2751. ‡ $ls -C *.o                                                    ‡
  2752. ‡ funct1.o           funct2.o          main.o                   ‡
  2753. ‡ $                                                             ‡
  2754. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2755.  
  2756. The -c options causes the compilation system to suppress the link
  2757. edit phase.  This produces an object file or files, in this example
  2758. (main.o funct1.o funct2.o), that can be link edited at a later time
  2759. with the cc command with no options.
  2760. 5.8  FORTRAN: Sample Program a Main and Two Subroutines
  2761.  
  2762.  
  2763. There are several conventions for use with the FORTRAN compiler.
  2764. They are:
  2765.  
  2766.      1.   The name of the file containing the FORTRAN source code
  2767.           must end with .f.
  2768.  
  2769.      2.   The compiler is invoked with f77.
  2770.  
  2771.      3.   Several options are available with the compiler.
  2772.           (-c, -o, -p, -S)
  2773.  
  2774.      4.   Preconnections are made for stdin (unit5) and stdout
  2775.           (unit6).
  2776.  
  2777. This is the FORTRAN source code example to be used in the following
  2778. discussions of the FORTRAN compiler.
  2779.  
  2780. Sample Session:
  2781.  
  2782. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2783. ‡ $cat hello.f                                                  ‡
  2784. ‡       program calling                                         ‡
  2785. ‡       write(6,100)                                            ‡
  2786. ‡ 100   format (' Hello from main!',/)                          ‡
  2787. ‡       write(6,110)                                            ‡
  2788. ‡ 110   format(' Calling subroutine1!',/)                       ‡
  2789. ‡       call sub1                                               ‡
  2790. ‡       write(6,120)                                            ‡
  2791. ‡ 120   format(t15' Back from subroutine1!',/)                  ‡
  2792. ‡       write(6,130)                                            ‡
  2793. ‡ 130   format(' Calling subroutine2!',/)                       ‡
  2794. ‡       call sub2                                               ‡
  2795. ‡       write(6,140)                                            ‡
  2796. ‡ 140   format(t15' Back from subroutine2!',/)                  ‡
  2797. ‡       write(6,150)                                            ‡
  2798. ‡ 150   format(' That's all, folks!')                           ‡
  2799. ‡       end                                                     ‡
  2800. ‡       subroutine sub1                                         ‡
  2801. ‡       write(6,200)                                            ‡
  2802. ‡ 200   format(t20,' Hello from subroutine1!',/)                ‡
  2803. ‡       end                                                     ‡
  2804. ‡       subroutine sub2                                         ‡
  2805. ‡       write(6,210)                                            ‡
  2806. ‡ 210   format(t20,' Hello from subroutine2!',/)                ‡
  2807. ‡       end                                                     ‡
  2808. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2809. 5.9  FORTRAN: Compiling a Program
  2810.  
  2811. The FORTRAN compiler is invoked with the following command:
  2812.  
  2813. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2814. ”  Command Format:  f77                                         ”
  2815. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2816.  
  2817. To compile the above program into an executable program, use the
  2818. following command at the command line.
  2819.  
  2820. Sample Session:
  2821.  
  2822. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2823. ‡ $f77 hello.f                                                  ‡
  2824. ‡ $                                                             ‡
  2825. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2826.  
  2827. Without any options, f77 accepts FORTRAN source code and assembly
  2828. language programs that follow the conventions outlined above.  It
  2829. will compile, assemble, and load these programs to produce an
  2830. executable called a.out.  The f77 utility outputs the object code
  2831. into files with the same base filename (everything before the
  2832. period) as the source but with a filename extension of .o.
  2833. The a.out stands for assembly output.  This is the default.
  2834.  
  2835. Sample Session:
  2836.  
  2837. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2838. ‡ $f77 hello.f                                                  ‡
  2839. ‡ $a.out                                                        ‡
  2840. ‡ Hello from main!                                              ‡
  2841. ‡                                                               ‡
  2842. ‡ Calling function1!                                            ‡
  2843. ‡                                                               ‡
  2844. ‡              Hello from function1!                            ‡
  2845. ‡                                                               ‡
  2846. ‡         Back from function1!                                  ‡
  2847. ‡                                                               ‡
  2848. ‡ Calling function2!                                            ‡
  2849. ‡                                                               ‡
  2850. ‡              Hello from function2!                            ‡
  2851. ‡                                                               ‡
  2852. ‡         Back from function2!                                  ‡
  2853. ‡                                                               ‡
  2854. ‡ That's all!                                                   ‡
  2855. ‡ $                                                             ‡
  2856. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2857.  
  2858.  
  2859.  
  2860.  
  2861. NOTE:     The a.out file that was created by the f77 utility has
  2862.           the following permissions:
  2863.  
  2864.           user - read, write, and execute 
  2865.           group - read and execute
  2866.           other - read and execute
  2867.  
  2868. It is not necessary for you to change the permissions using the
  2869. chmod command because the f77 utility set the execute permissions
  2870. for you.
  2871. 5.10  FORTRAN: Renaming the Executable Module
  2872.  
  2873. You can rename the executable module using the mv command.  The
  2874. file permissions will be the same as before the file is renamed.
  2875.  
  2876. Sample Session:
  2877.  
  2878. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2879. ‡ $mv a.out hello                                               ‡
  2880. ‡ $hello                                                        ‡
  2881. ‡ Hello from main!                                              ‡
  2882. ‡                                                               ‡
  2883. ‡ Calling function1!                                            ‡
  2884. ‡                                                               ‡
  2885. ‡              Hello from function1!                            ‡
  2886. ‡                                                               ‡
  2887. ‡         Back from function1!                                  ‡
  2888. ‡                                                               ‡
  2889. ‡ Calling function2!                                            ‡
  2890. ‡                                                               ‡
  2891. ‡              Hello from function2!                            ‡
  2892. ‡                                                               ‡
  2893. ‡         Back from function2!                                  ‡
  2894. ‡                                                               ‡
  2895. ‡ That's all!                                                   ‡
  2896. ‡ $                                                             ‡
  2897. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2898. 5.11  FORTRAN: Giving a Name to the Output File
  2899.  
  2900. It is possible to have the output sent to a file you specify
  2901. instead of the default, a.out, by using the following command:
  2902.  
  2903. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2904. ”  Command Format:  f77 -o output source                        ”
  2905. ”                                                               ”
  2906. ”  output - the name of the executable file                     ”
  2907. ”                                                               ”
  2908. ”  source - the name of the Fortran source code file            ”
  2909. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2910.                                                                 
  2911. The -o option tells the f77 utility to tell the link editor to use
  2912. the specified name for the output instead of the default a.out.
  2913.  
  2914. NOTE:     It is not necessary for the -o option to appear after
  2915.           the f77 command.  The filename that appears after the -
  2916.           o is the name of the output file.  For example, f77
  2917.           source -o output is the same as f77 -o output source.
  2918.  
  2919. Sample Session:
  2920.  
  2921. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2922. ‡ $f77 -o hello hello.f                                         ‡
  2923. ‡ $hello                                                        ‡
  2924. ‡ Hello from main!                                              ‡
  2925. ‡ Calling function1!                                            ‡
  2926. ‡                                                               ‡
  2927. ‡              Hello from function1!                            ‡
  2928. ‡                                                               ‡
  2929. ‡         Back from function1!                                  ‡
  2930. ‡                                                               ‡
  2931. ‡ Calling function2!                                            ‡
  2932. ‡                                                               ‡
  2933. ‡              Hello from function2!                            ‡
  2934. ‡                                                               ‡
  2935. ‡         Back from function2!                                  ‡
  2936. ‡                                                               ‡
  2937. ‡ That's all!                                                   ‡
  2938. ‡ $                                                             ‡
  2939. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2940. 5.12  FORTRAN: Producing an Assembly Listing
  2941.  
  2942. This option causes f77 to compile Fortran programs and leave the
  2943. corresponding assembly language source programs in a file with
  2944. filename extensions of .s.
  2945.  
  2946. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  2947. ”  Command Format:  f77 -S hello.f                              ”
  2948. ”                                                               ”
  2949. ”  -S = Compile only                                            ”
  2950. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  2951.  
  2952. Sample Session:
  2953.  
  2954. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2955. ‡ $f77 -S  hello.f                                              ‡
  2956. ‡ $ls -C                                                        ‡
  2957. ‡ example.f         hello     hex.c     octal.c                 ‡
  2958. ‡ hello.c           hello.s   multiply.c                        ‡
  2959. ‡ $                                                             ‡
  2960. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2961.  
  2962. The file hello.s contains the assembly listing.
  2963. 5.13  FORTRAN: Main and Two Subroutines in Three Separate Source
  2964.       Files
  2965.  
  2966. Sample Session:
  2967.  
  2968. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  2969. ‡ $cat main.f                                                   ‡
  2970. ‡      program calling                                          ‡
  2971. ‡      write(6,100)                                             ‡
  2972. ‡ 100  format (' Hello from main!',/)                           ‡
  2973. ‡      write(6,110)                                             ‡
  2974. ‡ 110  format(' Calling subroutine1!',/)                        ‡
  2975. ‡      call sub1                                                ‡
  2976. ‡      write(6,120)                                             ‡
  2977. ‡ 120  format(t15' Back from subroutine1!',/)                   ‡
  2978. ‡      write(6,130)                                             ‡
  2979. ‡ 130  format(' Calling subroutine2!',/)                        ‡
  2980. ‡      call sub2                                                ‡
  2981. ‡      write(6,140)                                             ‡
  2982. ‡ 140  format(t15' Back from subroutine2!',/)                   ‡
  2983. ‡      write(6,150)                                             ‡
  2984. ‡ 150  format(' That's all, folks!')                            ‡
  2985. ‡      end                                                      ‡
  2986. ‡ $cat sub1.f                                                   ‡
  2987. ‡      subroutine sub1                                          ‡
  2988. ‡      write(6,200)                                             ‡
  2989. ‡ 200  format(t20,' Hello from subroutine1!',/)                 ‡
  2990. ‡      end                                                      ‡
  2991. ‡ $cat sub2.f                                                   ‡
  2992. ‡      subroutine sub2                                          ‡
  2993. ‡      write(6,210)                                             ‡
  2994. ‡ 210  format(t20,' Hello from subroutine2!',/)                 ‡
  2995. ‡      end                                                      ‡
  2996. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  2997. 5.14  FORTRAN: Compiling But Not Producing an Executable Module
  2998.  
  2999.  
  3000. Using the above program, the following command will compile but
  3001. not produce an executable module.
  3002.  
  3003. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3004. ”  Command Format:  f77 -c main.f sub1.f sub2.f                 ”
  3005. ”                                                               ”
  3006. ”  -c = Compile, but do not load object files.  This option     ”
  3007. ”       causes f77 to compile and/or assemble source code       ”
  3008. ”       programs and leave the corresponding object programs    ”
  3009. ”       in files with filename extensions of .o.                ”
  3010. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3011.  
  3012. Sample Session:
  3013.  
  3014. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3015. ‡ $f77 -c main.f sub1.f sub2.f                                  ‡
  3016. ‡ main.f:                                                       ‡
  3017. ‡      MAIN: calling:                                           ‡
  3018. ‡ sub1.f:                                                       ‡
  3019. ‡      sub1:                                                    ‡
  3020. ‡ sub2.f:                                                       ‡
  3021. ‡      sub2:                                                    ‡
  3022. ‡ $ls a.out *.o                                                 ‡
  3023. ‡ a.out not found                                               ‡
  3024. ‡ funct1.o                                                      ‡
  3025. ‡ funct2.o                                                      ‡
  3026. ‡ hello.o                                                       ‡
  3027. ‡ main.o                                                        ‡
  3028. ‡ sub1.o                                                        ‡
  3029. ‡ sub2.o                                                        ‡
  3030. ‡ $                                                             ‡
  3031. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3032.  
  3033. The -c options causes the compilation system to suppress the link
  3034. edit phase.  This produces an object file or files, in this example
  3035. (main.o sub1.o sub2.o), that can be link edited at a later time
  3036. with the f77 command with no options.
  3037. 5.15  FORTRAN: Compiling Object Files to Produce an Executable   
  3038.                Module
  3039.  
  3040. The command to produce an executable nodule from several object
  3041. files is done in the following manner:
  3042.  
  3043. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3044. ”  Command Format:  f77 obj_1 obj_2 obj_3                       ”
  3045. ”                                                               ”
  3046. ”  obj_1 through obj_n - the object files                       ”
  3047. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3048.  
  3049. Sample Session:
  3050.  
  3051. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3052. ‡ $f77 main.o sub1.o sub2.o                                     ‡
  3053. ‡ $ls -C                                                        ‡
  3054. ‡ funct1.o funct2.o hello.o main.o sub1.o sub2.o a.out          ‡
  3055. ‡ $                                                             ‡
  3056. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3057. 5.16  COBOL: Sample Program with a Main and Two Subroutines
  3058.  
  3059.  
  3060. Sample Session:
  3061.  
  3062. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3063. ‡ $cat teacher.cob                                              ‡
  3064. ‡ identification division.                                      ‡
  3065. ‡ program-id. teacher.                                          ‡
  3066. ‡ environment division.                                         ‡
  3067. ‡ configuration section.                                        ‡
  3068. ‡ data division.                                                ‡
  3069. ‡ working-storage section.                                      ‡
  3070. ‡ procedure division.                                           ‡
  3071. ‡ begin section.                                                ‡
  3072. ‡ begin-it.                                                     ‡
  3073. ‡      display " Hello from main!".                             ‡
  3074. ‡      display "  Calling subroutine1!".                        ‡
  3075. ‡      perform subroutine1.                                     ‡
  3076. ‡      display "               Back from subroutine1!".         ‡
  3077. ‡      display "  Calling subroutine2!".                        ‡
  3078. ‡      perform subroutine2.                                     ‡
  3079. ‡      display "               Back from subroutine2!".         ‡
  3080. ‡      display "  That's all, folks!".                          ‡
  3081. ‡      stop run.                                                ‡
  3082. ‡ subroutine1 section.                                          ‡
  3083. ‡ sub1.                                                         ‡
  3084. ‡      display "               Hello from subroutine1!".        ‡
  3085. ‡ subroutine2 section.                                          ‡
  3086. ‡ sub2.                                                         ‡
  3087. ‡      display "               Hello from subroutine2!".        ‡
  3088. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3089. 5.17  COBOL: Compiling a Program
  3090.  
  3091.  
  3092. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3093. ”  Command Format:  cobol source_filename                       ”
  3094. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3095.  
  3096. Three files are created by the compiler.  They are identified by
  3097. the same filename as the source code but with a different
  3098. extension.  They have the extensions .IDY, .INT, and .LST.
  3099.  
  3100. NOTE:     The extensions are uppercase characters.  UNIX is case 
  3101.           sensitive.
  3102.  
  3103.  
  3104. Sample Session:
  3105.  
  3106. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3107. ‡ $cobol teacher.cob                                            ‡
  3108. ‡ $ls teacher*                                                  ‡
  3109. ‡ teacher.IDY                                                   ‡
  3110. ‡ teacher.INT                                                   ‡
  3111. ‡ teacher.LST                                                   ‡
  3112. ‡ teacher.cob                                                   ‡
  3113. ‡ $                                                             ‡
  3114. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3115. 5.18  COBOL: Running a Program
  3116.  
  3117.  
  3118. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3119. ‡ $cbrun teacher.INT                                            ‡
  3120. ‡ Hello from Main!                                              ‡
  3121. ‡   Calling subroutine1!                                        ‡
  3122. ‡               Hello from subroutine1!                         ‡
  3123. ‡              Back from subroutine1!                           ‡
  3124. ‡   Calling subroutine2!                                        ‡
  3125. ‡               Hello from subroutine2!                         ‡
  3126. ‡              Back from subroutine2!                           ‡
  3127. ‡ That's all, folks!                                            ‡
  3128. ‡ $                                                             ‡
  3129. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3130.  
  3131.                                NOTES
  3132. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  3133. Workshop 5
  3134.  
  3135.  
  3136. This workshop will reinforce your understanding of the ideas
  3137. presented in Chapter 5. Login to the Multimax using the username
  3138. and password given to you by the instructor.  Each student is to
  3139. complete the entire workshop.
  3140.  
  3141. DESK EXERCISES
  3142.  
  3143.  
  3144.      1.   "C": What is the command to compile, assemble, and load
  3145.           source code programs?
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.      2.   "C": What is the filename extension that indicates a
  3153.           source code program? An assembly language program? An
  3154.           object code file?
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.      3.   "C": What is the default filename assigned to the
  3162.           executable file?
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.      4.   "C": What command can be used to rename the executable
  3171.           file produced by the cc compiler? What are the file
  3172.           protections associated with the executable?
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.      5.   "C": What option will produce an assembly listing? What
  3181.           is the filename extension of this file?
  3182.  
  3183.  
  3184.                    Continue on the next page   
  3185.      6.   "C": What command will compile the source code program
  3186.           but will not load object files but will keep the object
  3187.           files in files with extensions of .o?
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.      7.   FORTRAN: What is the command to invoke the compiler?
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.      8.   FORTRAN: What is the filename extension for source code
  3202.           programs?
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.      9.   FORTRAN: What is the name of the default
  3211.           executable file?
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.      10.  FORTRAN: How can you change the permissions on the
  3220.           executable module so anyone can execute it?
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.      11.  FORTRAN: What option on the call to the compiler will
  3229.           allow you to specify the name of the executable file?
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.                      Continue on the next page
  3236.      12.  FORTRAN: What option on the call to the compiler will
  3237.           produce an assembly listing?  What is the filename
  3238.           extension of this file?
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244.      13.  FORTRAN: What option will produce object modules but not
  3245.           produce an executable module?
  3246.  
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.      14.  FORTRAN: What command will produce an executable module
  3253.           from several object modules?
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.  
  3260.      15.  COBOL: What is the command to call the compiler?
  3261.  
  3262.  
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.      16.  COBOL: What are the three files created by the compiler?
  3270.           What are the filename extensions?
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.      17.  COBOL: Which of the three files that have been created
  3279.           are used to run the program?
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.                      Continue on the next page
  3288. COMPUTER EXERCISES 
  3289.  
  3290.  
  3291.      18.  Copy the following files from /user0/teacher:
  3292.  
  3293.           main.c   funct1.c   funct2.c
  3294.  
  3295.  
  3296.      Are these programs "C", FORTRAN, or COBOL? Compile these three
  3297.      files creating an executable file called main1.exe and then
  3298.      execute it. What are the file protections? Why?
  3299.  
  3300.  
  3301.  
  3302.      19.  Now append the three files into one file. Use
  3303.           output redirection. 
  3304.  
  3305.      Compile the file creating the executable file called main2.exe
  3306.      . Execute main2.exe.
  3307.  
  3308.  
  3309.  
  3310.  
  3311.      20.  Copy the following files from /user0/teacher:
  3312.  
  3313.           main.f   sub1.f   sub2.f
  3314.  
  3315.  
  3316.           Compile these three files creating an executable file
  3317.           called main1.exe . Execute main1.exe
  3318.  
  3319.  
  3320.      21.  Now append the three files into one file. 
  3321.  
  3322.           Compile the file creating the executable file called
  3323.           main2.exe . Execute main2.exe.
  3324.  
  3325.  
  3326.  
  3327.  
  3328.      22.  COBOL: Copy teacher.cob from /user0/teacher.
  3329.  
  3330.           Compile and run it.
  3331.                                NOTES
  3332. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  3333.                                NOTES
  3334. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  3335. 6.  UNIX TOOLS
  3336.  
  3337. 6.1  Processes
  3338.  
  3339. A process is the execution of a command by UNIX. Processes can also
  3340. be executed by the operating system itself.  Like the file
  3341. structure, the process structure is hierarchical. It contains
  3342. parents, children, and even a root. A parent can fork (or spawn)
  3343. a child process. That child can, in turn, fork other processes.
  3344. The first thing the operating system does to begin execution is to
  3345. create a single process, PID number 1. PID stands for Process
  3346. IDentification. This process will hold the same position as the
  3347. root directory in the file structure. This process is the ancestor
  3348. to all processes that each user works with. It forks a process for
  3349. each terminal. Each one of these processes becomes a Shell process
  3350. when the user logs on.
  3351.  
  3352. 6.2  Executing a Command
  3353.  
  3354. When you give a command to the Shell, it will fork a process to
  3355. execute the command. While the child process is executing the
  3356. command, the parent will go to sleep. Sleeping means that the
  3357. process will not use any CPU time. It remains inactive until it is
  3358. awakened. When the child process has finished executing the
  3359. command, it dies. The parent process, which is running the Shell,
  3360. wakes up and prompts you for another command.
  3361.  
  3362. When you request a process to run in the background (by ending the
  3363. command line with an &), the Shell forks a child process that is
  3364. allowed to run to completion. The parent process will report the
  3365. PID of the child process and them prompts you for another command.
  3366. The child and parent are now independent processes.
  3367.  
  3368. 6.3  Process Identification
  3369.  
  3370. The Unix operating system assigns a unique process identification
  3371. number (PID) to each process. It will keep the same PID as long as
  3372. the process is in existence. During one session, the same process
  3373. is always executing the login Shell. When you execute another
  3374. command a new process is forked and a new PID is assigned to that
  3375. process. When that child process is finished you are returned to
  3376. the login process, which is running the Shell,  and that parent
  3377. process has the same PID as when you logged on.
  3378. The Shell stores the PID in Shell variable called $$. The PID can
  3379. also be shown with the process status (ps) command. The format for
  3380. ps is as follows:
  3381.  
  3382.  
  3383. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3384. ”    Command Format:  ps [options]                              ”
  3385. ”                                                               ”
  3386. ”    See on-line manual for options                             ”
  3387. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3388.                                                                  
  3389. With no options given the ps command will give you certain
  3390. information about processes associated with the controlling
  3391. terminal.  The output consists of a short listing containing the
  3392. process id, terminal id, cumulative execution time, and the command
  3393. name. Otherwise, options will control the display.
  3394.  
  3395. Sample session:
  3396.  
  3397. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3398. ‡ $echo $$                                                                   ‡
  3399. ‡ 8347                                                                       ‡
  3400. ‡ $ps                                                                        ‡
  3401. ‡    PID TTY      TIME COMMAND                                               ‡
  3402. ‡   8347 rt021a0  0:03 ksh                                                   ‡
  3403. ‡   8376 rt021a0  0:06 ps                                                    ‡
  3404. ‡ $                                                                          ‡
  3405. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3406.  
  3407.  
  3408. The PID numbers of the Shell are the same in the sample session
  3409. because the shell will substitute its own PID number for $$. 
  3410. The Shell makes the substitution before it forks a new process to
  3411. execute the echo command. Therefore, echo will display the PID
  3412. number of the process that called it, not the PID of the process
  3413. that is executing it.
  3414. The -l option will display more information about the processes.
  3415.  
  3416.  
  3417. Sample Session:
  3418.  
  3419. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3420. ‡ $ps -l                                                                                   ‡
  3421. ‡     F S   UID   PID  PPID  C PRI NI     ADDR     SZ    WCHAN TTY      TIME COMD          ‡
  3422. ‡ f0000 S   115  8347   309  2  30 20  1009000    140    94014 rt021a0  0:03 ksh           ‡
  3423. ‡ f0000 O   115  8386  8347 16  68 20  1308000     72          rt021a0  0:01 ps            ‡
  3424. ‡ $ps -l                                                                                   ‡
  3425. ‡     F S   UID   PID  PPID  C PRI NI     ADDR     SZ    WCHAN TTY      TIME COMD          ‡
  3426. ‡ f0000 S   115  8347   309  1  30 20  1009000    140    94014 rt021a0  0:03 ksh           ‡
  3427. ‡ f0000 O   115  8387  8347 26  73 20  1146000     72          rt021a0  0:01 ps            ‡
  3428. ‡ $                                                                                        ‡
  3429. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3430.  
  3431. 6.4  grep: A Pattern Matching Filter
  3432.  
  3433. The grep utility can search through a file to see if it contains
  3434. a specified string of characters. The utility will not change the 
  3435. file it searches but displays each line that contains the string. 
  3436. The format for the string is:
  3437.  
  3438.  
  3439. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3440. ”  Command Format:  grep [options] limited_regular-expression [file]         ”
  3441. ”                                                                            ”
  3442. ”    Use the man command for a complete list of options                      ”
  3443. ”                                                                            ”
  3444. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3445.  
  3446. The grep utility searches files for a pattern and displays all 
  3447. lines that contain the pattern. It uses limited-regular-
  3448. expressions (these are expressions that have string values that 
  3449. use a subset of all the possible alphanumeric and special 
  3450. characters) like those used with ed to match the patterns. 
  3451.  
  3452. Be careful using the characters $, *, [, ^, |, (, ), and \ in the
  3453. regular expression because they will be evaluated by the shell. 
  3454. It is good practice to enclose the regular expression in single 
  3455. quotes. This will prevent the shell from evaluating these special
  3456. characters.
  3457.  
  3458. The grep utility will assume standard input if no files are  given. 
  3459. Normally, each line found in the file will be displayed  to
  3460. standard output.
  3461.  
  3462. Sample session:
  3463.  
  3464. .................................................................
  3465. .    $grep 'disc' memo                                          .
  3466. .................................................................
  3467.  
  3468. This command will search the file "memo" for the string "disc". It
  3469. will include words like discover and indiscreet because they
  3470. contain the characters "disc". The single quote marks are not
  3471. necessary and for this example they wouldn't have made any
  3472. difference. They do allow you to include spaces in the search
  3473. pattern. 
  3474. 6.4.1  More on Regular Expressions
  3475.  
  3476. The grep command can be best understood by a discussion of regular
  3477. expressions. Let's create a database of phone numbers called
  3478. phone.lis and then use regular expressions to search through the
  3479. database. Here is as listing of the contents of phone.lis
  3480.  
  3481. Sample session:
  3482.  
  3483. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3484. ‡    $cat phone.lis                                             ‡
  3485. ‡    Smith, Joan              7-7989                            ‡
  3486. ‡    Adams, Fran              2-3876                            ‡
  3487. ‡    StClair, Fred            4-6122                            ‡
  3488. ‡    Jones, Ted               1-3745                            ‡
  3489. ‡    Stair, Rich              5-5972                            ‡
  3490. ‡    Benson, Sam              4-5587                            ‡
  3491. ‡    $                                                          ‡
  3492. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3493.  
  3494. The format for the records in this database is:
  3495.                                              
  3496.      Last name, First name <tab>   #-####
  3497.  
  3498. Using the database (phone.lis) above. What grep command would we
  3499. use to search through the database and get all the records that
  3500. had a person whose name contains an "S".
  3501.  
  3502. An alphabetic character represents itself.
  3503.  
  3504. Sample session:
  3505.  
  3506. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3507. ‡    $grep S phone.lis                                          ‡
  3508. ‡    Smith, Joan              7-7989                            ‡
  3509. ‡    StClair, Fred            4-6122                            ‡
  3510. ‡    Stair, Rich              5-5972                            ‡
  3511. ‡    Benson, Sam              4-5587                            ‡
  3512. ‡    $                                                          ‡
  3513. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3514.  
  3515. This grep command searched for the string "S" and then listed all
  3516. the lines in phone.lis that matched.
  3517. A single . (dot) is used to represent any single character.
  3518.  
  3519. Sample session:
  3520.  
  3521. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3522. ‡    $grep .S phone.lis                                         ‡
  3523. ‡    Benson, Sam         4-5587                                 ‡
  3524. ‡    $                                                          ‡
  3525. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3526.  
  3527. A $ represents the end of the line.
  3528.  
  3529. Sample session:
  3530.  
  3531. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3532. ‡    $grep 5$ phone.lis                                         ‡
  3533. ‡    Jones, Ted         1-3745                                  ‡
  3534. ‡    $                                                          ‡
  3535. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3536.  
  3537. A ^ represents the beginning of the line
  3538.  
  3539. Sample session:
  3540.  
  3541. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3542. ‡    $grep ^S phone.lis                                         ‡
  3543. ‡    Smith, Joan         7-7989                                 ‡
  3544. ‡    StClair, Fred       4-6122                                 ‡
  3545. ‡    Stair, Rich         5-5972                                 ‡
  3546. ‡    $                                                          ‡
  3547. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3548.  
  3549. Regular expressions must get to grep in order for them to be
  3550. evaluated properly. Let's say we want to get the records of
  3551. employees that have a phone number that begins with a "4".
  3552.  
  3553. What does the following expression do?
  3554.  
  3555. Sample session:
  3556.  
  3557. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3558. ‡    $grep <tab>4 phone.lis                                     ‡
  3559. ‡    StClair, Fred        4-6122                                ‡
  3560. ‡    Jones, Ted           1-3745                                ‡
  3561. ‡    Benson, Sam          4-5587                                ‡
  3562. ‡    $                                                          ‡
  3563. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3564.  
  3565. Why did we get the record of Ted Jones? The tab character was 
  3566. evaluated by the shell and so the search was actually made looking
  3567. for a "4". This is the same as if we had entered $grep 4 phone.lis.
  3568. We must prevent the shell from evaluating these characters, this
  3569. is done with the \ (backslash) character as shown in the next
  3570. example.
  3571.  
  3572. Sample session:
  3573.  
  3574. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3575. ‡    $grep \<tab>4 phone.lis                                    ‡
  3576. ‡    StClair, Fred                4-6122                        ‡
  3577. ‡    Benson, Sam                  4-5587                        ‡
  3578. ‡    $                                                          ‡
  3579. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3580.  
  3581. Now it worked properly. It searched for a <tab> character       
  3582. followed by the number 4. The [] (left and right brackets) are used
  3583. to identify a range of characters.
  3584.  
  3585. Sample session:
  3586.  
  3587. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3588. ‡    $grep \[AF] phone.lis                                      ‡
  3589. ‡    Adams, Fran             2-3876                             ‡
  3590. ‡    StClair, Fred           4-6122                             ‡
  3591. ‡    $                                                          ‡
  3592. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3593.  
  3594. Why do [] need to be quoted? In the previous example the search 
  3595. makes a match on "A" or "F" . 
  3596.  
  3597. A - (dash) can indicate inclusion. For example, we want to make a
  3598. match on a phone number that has a 1, 2, 3, or 4. How can this be
  3599. done? Here's an example:
  3600.  
  3601. Sample Session:
  3602.  
  3603. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3604. ‡    $grep \[1-4] phone.lis                                     ‡
  3605. ‡    Adams, Fran                2-3876                          ‡
  3606. ‡    StClair, Fred              4-6122                          ‡
  3607. ‡    Jones, Ted                 1-3745                          ‡
  3608. ‡    Stair, Rich                5-5972                          ‡
  3609. ‡    Benson, Sam                4-5587                          ‡
  3610. ‡    $                                                          ‡
  3611. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3612.  
  3613. A ^ character looks for all characters NOT inside the [] brackets. 
  3614.  
  3615. For example,
  3616.  
  3617.      [^0-9]    matches all non-digits
  3618.  
  3619.      [^a-zA-Z] matches all non-alphabetic characters
  3620.  
  3621.      Note: \, *, and $ lose their meta-character meanings inside
  3622. the []. Also the ^ character is special only if it appears first.
  3623.  
  3624. What is the following command searching for?
  3625.  
  3626. Sample Session:
  3627.  
  3628. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3629. ‡    $grep '[^789]$' phone.lis                                  ‡
  3630. ‡    Adams, Fran                  2-3876                        ‡
  3631. ‡    StClair, Fred                4-6122                        ‡
  3632. ‡    Jones, Ted                   1-3745                        ‡
  3633. ‡    Stair, Rich                  5-5972                        ‡
  3634. ‡    $                                                          ‡
  3635. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3636.                                                                  
  3637. 6.4.2  Closure
  3638.  
  3639. The * (asterisk) represents zero or more of the characters
  3640. preceding the asterisk.
  3641.  
  3642.      A*   represents 0 or more As.
  3643.  
  3644.      AA*  represents 1 or more As.
  3645.  
  3646.      [0-9]*$  0 or more digits at the end of a line 
  3647.                (last four digits in a phone number)
  3648.  
  3649.      .*   represents 0 or more of any character.
  3650.  
  3651.  
  3652. How would you write a grep command using regular expressions to
  3653. find the last name starting with an "S" and the first name with an
  3654. "F"?
  3655.  
  3656.  
  3657.      ^S   Begins with an "S"
  3658.  
  3659.      .*,F Any number of characters before ,F
  3660.  
  3661. Sample session:
  3662.  
  3663. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3664. ‡    $grep ^S.\*,F phone.lis                                    ‡
  3665. ‡    StClair, Fred     4-6122                                   ‡
  3666. ‡    $                                                          ‡
  3667. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3668.                                                                  
  3669. Note: The * (asterisk) was quoted so the shell didn't try to
  3670. evaluate it.
  3671.  
  3672. It is very desireable to quote the entire string to keep the shell
  3673. from doing an expansion or substitution. It also increases
  3674. readability of the regular expression as in the following example:
  3675.  
  3676. Sample session:
  3677.  
  3678. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3679. ‡    $grep '^S.*, F' phone.lis                                  ‡
  3680. ‡    StClair, Fred     4-6122                                   ‡
  3681. ‡    $                                                          ‡
  3682. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3683.                                                                 
  3684. 6.4.3  Some Nice grep Options 
  3685.  
  3686. The grep provides several options that modify how the search is
  3687. performed.
  3688.  
  3689.      -c   Report count of matching lines only
  3690.  
  3691.      -v   Print those lines that don't match the pattern.
  3692.  
  3693. What will these lines print?
  3694.  
  3695. Sample session:
  3696.  
  3697. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3698. ‡     $grep -c '[J-Z]' phone.lis                                ‡
  3699. ‡     5                                                         ‡
  3700. ‡     $                                                         ‡
  3701. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3702.                                                                  
  3703. Why did we get this result? Let's analyze the command. In       
  3704. English, this command could be interpreted to mean "Tell me how
  3705. many records in the file "phone.lis" contain a letter from the set
  3706. J through and including Z."  Look at the phone.lis file and see
  3707. that five records fit this restriction.
  3708. So the answer is 5.
  3709.  
  3710. Now look at another example and see what this one does.
  3711.  
  3712. Sample session:
  3713.  
  3714. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3715. ‡    $grep -v '[J-Z]' phone.lis                                 ‡
  3716. ‡    Adams,Fran        2-3876                                   ‡
  3717. ‡    $                                                          ‡
  3718. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3719.  
  3720. Why is this the only record that was found? The -v option says to
  3721. select records that don't match the pattern. This is the same
  3722. pattern as the previous example and therefore it selects records
  3723. that don't match the pattern. The "Adams" record is the only one
  3724. that doesn't make a match. It doesn't have a character from the set
  3725. J through and Z.
  3726.  
  3727.  
  3728. 6.4.4  Summary of Regular Expression Characters
  3729.  
  3730.      ^         Beginning of the line
  3731.  
  3732.      $         End of the line
  3733.  
  3734.      *         0 or more preceding characters
  3735.  
  3736.      .         Any single character
  3737.  
  3738.      [...]          A range of characters
  3739.  
  3740.      [^...]    Exclusion range of characters
  3741.  
  3742.  
  3743. 6.5  sed: Edit a File to Standard Output
  3744.  
  3745. UNIX provides a method of editing streams of data. It is the sed
  3746. utility.  The name of this utility is derived from Stream EDitor.
  3747. This is not the same as the vi editor. The vi editor edits text in
  3748. a file. The sed utility edits text in a stream. In order to edit
  3749. a character stream two things are required.  First, the line to
  3750. edit must be identified (regular expressions) and second, how to
  3751. edit the line.
  3752.  
  3753. The formal form for the sed utility is as follows:
  3754.  
  3755. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3756. ”                                                               ”
  3757. ”    Command Format: sed [-n] [-e script] [-f sfile] [files]    ”
  3758. ”                                                               ”
  3759. ”    Details in on-line man pages                               ”
  3760. ”                                                               ”
  3761. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3762.  
  3763. The sed utility copies the named files (standard input default) to
  3764. the standard output, edited according to a set (script) of
  3765. commands. The -f options cause the script to be taken from file
  3766. "sfile".
  3767.  
  3768. The general form is:
  3769.  
  3770.      $sed /address/instruction
  3771.  
  3772. Note:     If no address is specified, all lines are chosen to edit.
  3773.  
  3774.  
  3775. 'sed' addresses can be line numbers or regular expressions.
  3776.  
  3777. Example:
  3778.  
  3779.      line numbers        2,4
  3780.                          2,$  ($ represents the last line)
  3781.  
  3782.      textual address     /regular-expression/
  3783.  
  3784.  
  3785.  
  3786. Note:     Forward slashes enclose textual addresses
  3787.  
  3788. The sed instructions indicate what editing function to perform.
  3789. Here some useful sed instructions:
  3790.  
  3791.      s         substitute
  3792.  
  3793.      d         delete
  3794.  
  3795. Note: Most sed command lines contain spaces or metacharacters and
  3796. they should be quoted to protect them from the shell. There are
  3797. many more editing commands provided by sed. Here is a sample sed
  3798. command to edit the records in the database file that we are
  3799. already familiar with, namely, phone.lis:
  3800.  
  3801. Sample session:
  3802.  
  3803. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3804. ‡    $sed /s/Smith/Smythe/ phone.lis                            ‡
  3805. ‡    Smythe, Joan        7-7989                                 ‡
  3806. ‡    Adams, Fran         2-3876                                 ‡
  3807. ‡    StClair, Fred       4-6122                                 ‡
  3808. ‡    Jones, Ted          1-3745                                 ‡
  3809. ‡    Stair, Rich         5-5972                                 ‡
  3810. ‡    Benson, Sam         4-5587                                 ‡
  3811. ‡    $                                                          ‡
  3812. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3813.                                                                  
  3814. sed is an editor . It simply copies the standard input to the
  3815. standard output, editing the lines that match the indicated
  3816. address. The original file is not changed. 
  3817.  
  3818. Here's another example of a sed command.
  3819.  
  3820. Sample session:
  3821.  
  3822. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3823. ‡    $sed '2,4 s/2$/3/' phone.lis                               ‡
  3824. ‡    Smith, Joan         7-7989                                 ‡
  3825. ‡    Adams, Fran         2-3876                                 ‡
  3826. ‡    StClair, Fred       4-6123                                 ‡
  3827. ‡    Jones, Ted          1-3745                                 ‡
  3828. ‡    Stair, Rich         5-5972                                 ‡
  3829. ‡    Benson, Sam         4-5587                                 ‡
  3830. ‡    $                                                          ‡
  3831. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3832.  
  3833. What does this sed command do?  If you read command in English it
  3834. reads like this: On lines 2 through 4 substitute the 2 at the end
  3835. of the line with a 3.  Notice that the phone number for
  3836. StClair,Fred changed from 4-6122 to 4-6123.  The number for
  3837. Stair,Rich didn't change because it was outside the range.
  3838.  
  3839. The sed utility can also be use to delete parts of a line of data.
  3840. This is done by substituting nothing for the parts you want to
  3841. delete. It looks like this:
  3842.  
  3843. Sample session:
  3844.  
  3845. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3846. ‡    $sed 's/^.*, //' phone.lis                                 ‡
  3847. ‡    Joan               7-7989                                  ‡
  3848. ‡    Fran               2-3876                                  ‡
  3849. ‡    Fred               4-6122                                  ‡
  3850. ‡    Ted                1-3745                                  ‡
  3851. ‡    Rich               5-5972                                  ‡
  3852. ‡    Sam                4-5587                                  ‡
  3853. ‡    $                                                          ‡
  3854. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3855.  
  3856. Reading this command it means:                                   
  3857.  
  3858. Substitute from the beginning of the line followed by any number
  3859. of characters followed by a comma with the null string (nothing).
  3860. This has the effect of removing the text.               
  3861.  
  3862. Here's a delete command and how it's used.
  3863.  
  3864. Sample session:
  3865.  
  3866. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3867. ‡    $sed d phone.lis                                           ‡
  3868. ‡    $                                                          ‡
  3869. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3870.  
  3871. Why is there no output? Well, it read standard input and did the
  3872. editing function on all the selected lines. Since no lines were
  3873. specified all lines were selected to be edited. The editing was to
  3874. delete the line.
  3875.  
  3876.  Question: Has the original file been destroyed?
  3877.  
  3878. Multiple commands are allowed in sed. Each instruction is applied
  3879. to each input line.
  3880.  
  3881. Sample session:
  3882.  
  3883. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  3884. ‡    $sed '/Stair/d                                             ‡
  3885. ‡    >/Adams/d' phone.lis                                       ‡
  3886. ‡    Smith, Joan         7-7989                                 ‡
  3887. ‡    StClair, Fred       4-6122                                 ‡
  3888. ‡    Jones, Ted          2-1136                                 ‡
  3889. ‡    Benson, Sam         4-5587                                 ‡
  3890. ‡    $                                                          ‡
  3891. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  3892.  
  3893. The records for Adams and Stair have both been removed from the
  3894. database.
  3895.  
  3896. Note:     The > character is the BourneShell secondary prompt.
  3897.  
  3898. 6.6  awk: A Pattern Matching Programming Language
  3899.  
  3900. Suppose you wanted to change the format of the database phone.lis
  3901. to be the first name followed by the last name. There is no easy
  3902. way to do this with sed. Fortunately, UNIX not only provides a
  3903. stream editor (sed) but it also has a formatting tool. The
  3904. formatting tool in UNIX is called awk. This tool is named after
  3905. authors who wrote it  Alfred V. Aho, Peter J. Weinberger, and Brian
  3906. W. Kerninghan so it really doesn't have any meaning.
  3907.  
  3908. The awk utility is a pattern scanning and processing language. It
  3909. will search one or more files for a specified pattern and then
  3910. performs an action, such as writing to standard output or
  3911. incrementing a counter when it finds a match. You can use awk to
  3912. generate reports or filter text. It works equally well with numbers
  3913. or text. The authors designed it to be easy to use and sacrificed
  3914. execution speed toward this end.
  3915.  
  3916. While the sed utility allows us to change the text in a stream,
  3917. awk allows us to rearrange, add, or delete text in a stream,
  3918. easily.
  3919.  
  3920. The awk takes advantage of many constructs from the C programming
  3921. language. It has the following features:
  3922.  
  3923.  
  3924.      flexible format
  3925.      conditional execution
  3926.      looping statements
  3927.      numeric variables
  3928.      string variables
  3929.      regular expressions
  3930.      C's printf
  3931.  
  3932.  
  3933. The awk will take it's input from the files you specify on the
  3934. command line or from standard input. The following is the format
  3935. for awk:
  3936.  
  3937. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  3938. ”                                                               ”
  3939. ”    Command format: awk [-Fc] [prog] [files]                   ”
  3940. ”                                                               ”
  3941. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  3942.  
  3943. The awk will scan each line of file for lines that match a set of
  3944. patterns specified by prog. With each pattern in prog there can be
  3945. an associated action to be performed when the line is found. The
  3946. set of patterns may appear literally as prog, or in a file
  3947. specified as -f file. The prog string should be enclosed in single
  3948. quotes to protect it from the Shell.
  3949.  
  3950. Files are read in order and if there are none specified the
  3951. standard input is read. Each line is matched against the pattern
  3952. portion of every pattern-action statement.  The associated action
  3953. is performed for each matched pattern.  An input line is made up
  3954. fields separated by white space.  $1, $2.. define the fields. $0
  3955. refers to the whole line.
  3956.  
  3957. A pattern-action statement has the form:
  3958.  
  3959.  
  3960.      pattern {action}
  3961.  
  3962.  
  3963. A missing action means print the line; a missing pattern always
  3964. makes a match. a statement can be one of the following:
  3965.  
  3966.  
  3967.      if (conditional) statement [else statement]
  3968.      while (conditional) statement
  3969.      for (expression;conditional;expression) statement
  3970.      break
  3971.      continue
  3972.      {[statement]...}
  3973.      variable=expression
  3974.      print [expression-list] [>expression]
  3975.      printf format [,expression-list][>expression]
  3976.      next # skip remaining pattern on this input line
  3977.      exit # skip the rest of the input
  3978.  
  3979.  
  3980. Statements are terminated by semi-colons, new-lines (CR), or right
  3981. braces.
  3982.  
  3983. Let's look at the syntax for awk in a little simpler manner.
  3984.  
  3985.  
  3986.      awk 'commands' [filename]
  3987.  
  3988.  
  3989. An awk program (commands) consists of a optional pattern to match
  3990. and an action to perform if a match is found on the current line.
  3991. This syntax looks like this:
  3992.  
  3993.  
  3994.      awk '/pattern/{action}' [filename]
  3995. The pattern used is a regular expression enclosed in forward
  3996. slashes. If no pattern is listed, the action will be performed for
  3997. every line. An action can contain several commands.  There can be
  3998. multiple patterns and actions.
  3999.  
  4000.      awk '/pattern1/{action1}
  4001.       /pattern2/{action2}' [filename}
  4002.  
  4003.  
  4004. One of awks commands is print. It puts the current line on standard
  4005. output.
  4006.  
  4007. Sample session:
  4008.  
  4009. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4010. ‡                                                               ‡
  4011. ‡   $awk '{print}' phone.lis                                    ‡
  4012. ‡   Smith, Joan         7-7989                                  ‡
  4013. ‡   Adams, Fran         2-3876                                  ‡
  4014. ‡   StClair, Fred       4-6122                                  ‡
  4015. ‡   Jones, Ted          1-3745                                  ‡
  4016. ‡   Stair, Rich         5-5972                                  ‡
  4017. ‡   Benson, Sam         4-5587                                  ‡
  4018. ‡   $                                                           ‡
  4019. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4020.  
  4021. The awk splits every input line at whitespace and keeps track of
  4022. the number of fields on each line and counts the number of lines
  4023. read. Each field is identified by its field number and a $.
  4024.  
  4025.      $1   Identifies the first field
  4026.  
  4027.      $2   Identifies the second field
  4028.  
  4029.      .
  4030.  
  4031.      $0   Identifies the entire line
  4032.  
  4033.      NF   Identifies the number of fields on the line
  4034.  
  4035.      NR   Identifies the number of lines that have been read
  4036. Sample session:
  4037.  
  4038. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4039. ‡                                                               ‡
  4040. ‡    $awk '{print NR,$1}' phone.lis                             ‡
  4041. ‡    1 Smith,                                                   ‡
  4042. ‡    2 Adams,                                                   ‡
  4043. ‡    3 StClair,                                                 ‡
  4044. ‡    4 Jones,                                                   ‡
  4045. ‡    5 Stair,                                                   ‡
  4046. ‡    6 Benson,                                                  ‡
  4047. ‡    $                                                          ‡
  4048. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4049.  
  4050. To change the order of the names in phone.lis use awk. The comma
  4051. in the print command tells awk to separate each field with a space.
  4052. Without the comma, the output would have no spacing.
  4053.  
  4054. Sample session:
  4055.  
  4056. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4057. ‡    $awk '{print $2, $1 "<tab>"$3}' phone.lis                  ‡
  4058. ‡    Joan Smith,        7-7989                                  ‡
  4059. ‡    Fran Adams,        2-3876                                  ‡
  4060. ‡    Fred StClair,      4-6122                                  ‡
  4061. ‡    Ted Jones,         1-3745                                  ‡
  4062. ‡    Rich Stair,        5-5972                                  ‡
  4063. ‡    Sam Benson,        4-5587                                  ‡
  4064. ‡    $                                                          ‡
  4065. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4066.                                                                  
  4067. 6.7  sort: Sort a File
  4068.  
  4069. The sort utility sorts line of all the named files together and
  4070. writes the result to standard output. The standard input is used
  4071. if - is used as a file name or no input files are specified.
  4072.  
  4073. Comparisons are based one or more sort keys extracted from each
  4074. line of input. There is only one key by default, that's the entire
  4075. line, and ordering is lexicographic by bytes in machine collating
  4076. sequence.
  4077.  
  4078. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  4079. ”                                                               ”
  4080. ”    Command format: sort [-cmu][-ooutput][-ykmem][-zrecsz]     ”
  4081. ”                         [-dfiMnr][-btx][+pos][-pos2][files]   ”
  4082. ”                                                               ”
  4083. ”     See on-line manual for options etc.                       ”
  4084. ”                                                               ”
  4085. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  4086.  
  4087. The easiest way to use sort is to add it at the end af a pipeline.
  4088. What does the following command line accomplish:
  4089.  
  4090. Sample session:
  4091.  
  4092. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4093. ‡                                                               ‡
  4094. ‡   $grep '<tab>[45]' phone.lis | sed 's/<tab>/<tab>73/' | sort ‡
  4095. ‡   Benson, Sam         734-5587                                ‡
  4096. ‡   StClair, Fred       734-6122                                ‡
  4097. ‡   Stair, Rich         735-5972                                ‡
  4098. ‡   $                                                           ‡
  4099. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4100.  
  4101. The grep command will select only those records that have a 4 of 
  4102. a 5 in the phone number, those records are then sent to sed which
  4103. will add "73" just after the tab character, then the records are
  4104. sent to sort and put in alphabetical order. Notice that there is
  4105. a problem here, should StClair come before Stair in an alphabetical
  4106. listing? The answer is NO. Why did this happen? It occurred because
  4107. of the collating sequence for the default sort.
  4108.  
  4109. This can be fixed by specifying some options on the call to the
  4110. sort utility. Here are some options for sort. Let's see if we can
  4111. determine how to remedy the problem discovered in the default sort.
  4112.  
  4113.  
  4114. Sort options:
  4115.  
  4116.      -f   Fold lower case into upper case
  4117.      -r   Reverse the sort from highest to lowest
  4118.      -b   Ignore leading blank spaces
  4119.      -d   Dictionary sort - ignore non alphanumeric characters
  4120.      -m   Merge two sorted files together
  4121.      -n   Sort the list as numbers not digit characters
  4122.  
  4123. Notice the -f options folds lower case into upper case. This option
  4124. will make the sort for our problem work correctly. Here's the
  4125. sample.
  4126.  
  4127. Sample session:
  4128.                                                                  
  4129.         
  4130. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿             
  4131. ‡   $grep '<tab>[45]' phone.lis|sed 's/<tab>/<tab>73/'|sort -f  ‡    
  4132. ‡   Benson, Sam         734-5587                                ‡             
  4133. ‡   Stair, Rich         735-5972                                ‡             
  4134. ‡   StClair, Fred       734-6122                                ‡             
  4135. ‡   $                                                           ‡             
  4136. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4137.  
  4138. The sort can also be directed to use only a portion of the line as
  4139. a sorting key versus the entire line. The utility will
  4140. automatically break each line into fields at whitespace delimiters.
  4141. You can use a character other than whitespace by using the -t
  4142. option. The fields are set up like this:
  4143.  
  4144.  
  4145.         0     1        2
  4146.       /----|/---|/-------------|
  4147.      Adams, Fran         2-3876
  4148.  
  4149.    In order to sort by the second field here is the sort command
  4150. to enter.
  4151.  
  4152. Sample session:
  4153.  
  4154. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4155. ‡    $sort +1 phone.lis                                         ‡
  4156. ‡    Adams, Fran        2-3876                                  ‡
  4157. ‡    StClair, Fred      4-6122                                  ‡
  4158. ‡    Smith, Joan        7-7989                                  ‡
  4159. ‡    Stair, Rich        5-5972                                  ‡
  4160. ‡    Benson, Sam        4-5587                                  ‡
  4161. ‡    Jones, Ted         1-3745                                  ‡
  4162. ‡    $                                                          ‡
  4163. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4164.  
  4165. Here's a sample of a sort on the 3rd field.
  4166.  
  4167. Sample session:
  4168.  
  4169. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4170. ‡     $sort +2 phone.lis                                        ‡
  4171. ‡     Jones, Ted        1-3745                                  ‡
  4172. ‡     Adams, Fran       2-3876                                  ‡
  4173. ‡     Benson, Sam       4-5587                                  ‡
  4174. ‡     StClair, Fred     4-6122                                  ‡
  4175. ‡     Stair, Rich       5-5972                                  ‡
  4176. ‡     Smith, Joan       7-7989                                  ‡
  4177. ‡     $                                                         ‡
  4178. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4179.  
  4180. A sort can also be performed by a character position within a
  4181. field. Here's the sample.
  4182.  
  4183. Sample session:
  4184.  
  4185. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4186. ‡    $sort +2.4 phone.lis                                       ‡
  4187. ‡    StClair, Fred           4-6122                             ‡
  4188. ‡    Benson, Sam             4-5587                             ‡
  4189. ‡    Jones, Ted              1-3745                             ‡
  4190. ‡    Adams, Fran             2-3876                             ‡
  4191. ‡    Stair, Rich             5-5972                             ‡
  4192. ‡    Smith, Joan             7-7989                             ‡
  4193. ‡    $                                                          ‡
  4194. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4195.  
  4196. Note:     The first character of a field is the delimiter for that
  4197.           field        
  4198. 6.8  What Other Useful UNIX Tools are Available
  4199.  
  4200. As stated from the beginning, one of the maxims used to develop
  4201. UNIX was that tools would continue to be developed. Here is a  
  4202. list of tools that might be of interest to you.                  
  4203.  
  4204. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4205. ‡    UNIX Tool         Description                              ‡
  4206. ‡                                                               ‡
  4207. ‡    comm           Compares two sorted file and reports        ‡
  4208. ‡                   differences                                 ‡
  4209. ‡                                                               ‡
  4210. ‡    cut            Select columns or fields from lines in a    ‡
  4211. ‡                   field (System V only)                       ‡
  4212. ‡                                                               ‡
  4213. ‡    diff           Report the differences between two files    ‡
  4214. ‡                                                               ‡
  4215. ‡    join           Join lines in two files that contain a      ‡
  4216. ‡                   common field                                ‡
  4217. ‡                                                               ‡
  4218. ‡    pg             Show files (or standard input) on a terminal‡
  4219. ‡                   a screen at a time                          ‡
  4220. ‡                                                               ‡
  4221. ‡    od             Print the numeric equivalent of a file's    ‡
  4222. ‡                   content                                     ‡
  4223. ‡                                                               ‡
  4224. ‡    tail           List end of files (or standard input) on    ‡
  4225. ‡                   standard output                             ‡
  4226. ‡                                                               ‡
  4227. ‡    tee            Sends standard input to two different places‡
  4228. ‡                                                               ‡
  4229. ‡    tr             Transforms all occurrences of one character ‡ 
  4230. ‡                   into another                                ‡
  4231. ‡                                                               ‡
  4232. ‡                                                               ‡
  4233. ‡    wc             Count the characters, words, and lines in a ‡
  4234. ‡                   file                                        ‡
  4235. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4236.  
  4237. 6.9  Archiver and Library Maintainer
  4238.                                                                  
  4239. This command will maintain groups of files combined into a single
  4240. archive file.  The main use of ar is to create and update library
  4241. files as used by the link editor.  It can also be used for any
  4242. other similar purpose.  The file header consists of printable ASCII
  4243. characters.  If the archive consists of printable characters, then
  4244. the entire archive is also printable.
  4245.  
  4246. The format for the ar command is as follows:
  4247.                                                                  
  4248. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  4249. ” Command Format:  ar key [posname] afile [name]...             ”
  4250. ”                                                               ”
  4251. ” Unlike command options, the command key is required.  The key,”
  4252. ” usually a - sign, is formed with one of the following letters ”
  4253. ” drqtpmx.  Arguments to the key are made from one or more of   ”
  4254. ” the following set, vuaibcis.  See Appendix I for a complete   ”
  4255. ” list of command keys.                                         ”
  4256. ”                                                               ”
  4257. ” posname is an archive member name used as a reference for     ”
  4258. ” positioning other files in the archive.                       ”
  4259. ”                                                               ”
  4260. ” afile is the name of the archive.                             ”
  4261. ”                                                               ”
  4262. ” name[s] are the constituent files in the archive.             ”
  4263. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  4264.                                                                
  4265. To illustrate how to create and use an archive file, we will use
  4266. the "C" program called main.c and the two functions, funct1.c and
  4267. funct2.c.  First, create the object files that we intend to put
  4268. into the archive file.
  4269.  
  4270. Sample Session:
  4271.  
  4272. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4273. ‡ $cc -c main.c funct1.c funct2.c                               ‡
  4274. ‡ main.c:                                                       ‡
  4275. ‡ funct1.c:                                                     ‡
  4276. ‡ funct2.c:                                                     ‡
  4277. ‡ $ls -C *.o                                                    ‡
  4278. ‡ funct1.o funct2.o main.o                                      ‡
  4279. ‡ $                                                             ‡
  4280. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4281.  
  4282. Remember the -c option will not produce an executable module, but
  4283. it does create the object modules.  These object modules are file
  4284. files that we will place into an archive.
  4285.  
  4286. 6.9.1  ar: Creating an Archive File with Object Modules
  4287.  
  4288. In this call to ar, we will use the r command key which will
  4289. replace the named files in the archive.  The v option will give a
  4290. verbose file-by-file description of the making of the new archive
  4291. file.
  4292.  
  4293. Sample Session:
  4294.  
  4295. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4296. ‡ $ar rv functs.a funct1.o funct2.o                             ‡
  4297. ‡ a - funct1.o                                                  ‡
  4298. ‡ a - funct2.o                                                  ‡
  4299. ‡ ar: creating functs.a                                         ‡
  4300. ‡ $                                                             ‡
  4301. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4302.  
  4303. The name of the new archive file is functs.a.  The files that have
  4304. been added to that archive are funct1.o and funct2.o.  The file
  4305. protections for the new archive file are rw-r--r--.
  4306.  
  4307.  
  4308.  
  4309. 6.9.2  ar: Verifying the Contents of the Archive File
  4310.  
  4311. The key command to list the table of contents is t.  The t command
  4312. will print a table of contents of the archive file.  When the v
  4313. option is used with the t command it will give a long listing of
  4314. all information about the files.
  4315.  
  4316. Sample Session:
  4317.  
  4318. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4319. ‡ $ar tv functs.a                                               ‡
  4320. ‡ rw-r--r--    115/    200 448 Sep 27 09:56 1990 funct1.o       ‡
  4321. ‡ rw-r--r--    115/    200 448 Sep 27 09:56 1990 funct2.o       ‡
  4322. ‡ $                                                             ‡
  4323. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4324.  
  4325. This output shows that there are two members in this archive file,
  4326. namely, funct1.o and funct2.o.
  4327.  
  4328. The protections of these files is:
  4329.  
  4330.      owner - read and write
  4331.      group - read
  4332.      other - read
  4333.  
  4334. The fields are, left to right, the file protections, owner, group,
  4335. size (in bytes), creation date and time, and finally the name of
  4336. the constituent.
  4337.  
  4338. 6.9.3  ar: Removing Duplicate Object Files
  4339.  
  4340.  
  4341. Once the archive has been created and verified, the object files
  4342. in your directory can be deleted.  This can be accomplished with
  4343. the rm command.
  4344.  
  4345. Sample Session:
  4346.  
  4347. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4348. ‡ $rm funct?.o                                                  ‡
  4349. ‡ $                                                             ‡
  4350. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4351.  
  4352. The question mark (?) is a wildcard that stands for any single
  4353. character.  The files funct1.o and funct2.o no longer exist in your
  4354. subdirectory.
  4355.  
  4356. 6.9.4  ar: Compiling Main and Archive Files
  4357.  
  4358.  
  4359. Now that the object files, funct1.o and funct2.o, are in the
  4360. archive file functs.a you, can link them with main.o in the
  4361. following manner.
  4362.  
  4363. Sample Session:
  4364.  
  4365. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4366. ‡ $cc -o new_hello main.o functs.a                              ‡
  4367. ‡ $ls -la new_hello                                             ‡
  4368. ‡ -rwxr-xr-x  1 teacher class  17570  Sep 27 12:58 new_hello    ‡
  4369. ‡ $                                                             ‡
  4370. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4371.  
  4372.  
  4373.  
  4374. Workshop 6
  4375.  
  4376. This workshop will reinforce your understanding of the ideas
  4377. presented in Chapter 6. Login to the Multimax using the username
  4378. and password given to you by the instructor.  Each student is to
  4379. complete the entire workshop.
  4380.  
  4381. DESK EXERCISES 
  4382.  
  4383.  
  4384.      1.   What is a UNIX process?
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.      2.   When a command is given to the Shell it will fork a    
  4391.      child process to execute the command.
  4392.  
  4393.                       True/False
  4394.  
  4395.  
  4396.  
  4397.      3.   What is a process identification number (PID)?
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.      4.   What is the name of the Shell variable that contains   
  4404.      the current PID?
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.      5.   What is the UNIX command to find the PIDs associated   
  4411.      with the controlling terminal? What option is needed to     
  4412.      get detailed information?
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.      6.   What does the UNIX command grep do?
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.                      Continue on the next page
  4426.      7.   What do the following regular expressions represent?
  4427.  
  4428.  
  4429.                ^Ba
  4430.  
  4431.  
  4432.  
  4433.                .*
  4434.  
  4435.  
  4436.  
  4437.                BB*
  4438.  
  4439.  
  4440.  
  4441.                J*
  4442.  
  4443.  
  4444.  
  4445.                [0-9]*$
  4446.  
  4447.  
  4448.           
  4449.      8.   What does the UNIX command sed do?
  4450.  
  4451.  
  4452.  
  4453.  
  4454.  
  4455.  
  4456.      9.   What does the UNIX command awk do?
  4457.  
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.      10.  What does the UNIX command sort do?
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.      11.  What is the main use for the UNIX command ar?
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476.  
  4477.                      Continue on the next page
  4478.      COMPUTER EXERCISES
  4479.  
  4480.      Use the phone.lis database file to answer the following
  4481.      questions.
  4482.  
  4483.  
  4484.      12.  "I want to find all the phone numbers that begin with a
  4485.            4 and end with a 2"
  4486.  
  4487.  
  4488.  
  4489.  
  4490.  
  4491.      13.  "I can't remember the name but I believe the last name
  4492.            starts with an S and the first name with an F"
  4493.  
  4494.  
  4495.  
  4496.  
  4497.      14.  Find all the people with 3 character first names.
  4498.  
  4499.  
  4500.  
  4501.  
  4502.  
  4503.      15.  Write a grep command that finds all the phone numbers
  4504.           that don't begin with a 4, 5, or 6.
  4505.  
  4506.  
  4507.  
  4508.  
  4509.      16.  Write a grep command that finds all entries beginning
  4510.           with J-Z and ending with a 2 or 5.
  4511.  
  4512.  
  4513.  
  4514.  
  4515.  
  4516.      17.  Put a 23 in front of every phone number. (Hint:sed)
  4517.      
  4518.  
  4519.  
  4520.  
  4521.  
  4522.      18.  Replace the first name with the person's first initial
  4523.           and a period.
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.                      Continue on the next page
  4530.      19.  Task: A new phone system has been installed and people
  4531.           with phone extensions beginning with 4 or 5 now have a
  4532.           new prefix: 73. Create a file of only the people with
  4533.           the new phone numbers.
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.      
  4540.      20.  Print out the phone list showing last name and first   
  4541.           name in the following format and sorted by last name.
  4542.  
  4543.  
  4544.                     First name <tab> Last name
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.         That's enough, don't you think?
  4551.  
  4552.  
  4553.  
  4554. 7.  VAX DCL TO UNIX SHELL SCRIPT CONVERSION
  4555.  
  4556. This chapter will describe the steps necessary to convert DCL
  4557. command files into Shell scripts. It is not a one to one conversion
  4558. and many features found in one operating system are not found in
  4559. the other. This requires you to write shell scripts that emulate
  4560. features of the other. This is especially true of VAX and UNIX. The
  4561. best way to accomplish this is to know exactly what it is that the
  4562. command file does in VMS and then write the equivalent function in
  4563. a shell script. There are few features that are the similar and
  4564. those will be examined.
  4565.  
  4566. There is really no "best" way to approach this subject. VMS and
  4567. UNIX are both unique operating systems. Much of the material
  4568. covered in this course up to this point will be used in the
  4569. conversion process. We will start with a list of standard UNIX
  4570. tools and their VMS equivalents. This will give a you a flavor of
  4571. the kinds of tools each operating system has to offer.
  4572. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4573. ‡Major Tool                  VMS             UNIX               ‡
  4574. ˆ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜·
  4575. ‡                                                               ‡
  4576. ‡Editors                     EDT             ed                 ‡
  4577. ‡                            TECO            ex                 ‡
  4578. ‡                            TPU             vi                 ‡
  4579. ‡                                                               ‡
  4580. ‡Communications              MAIL            mail               ‡
  4581. ‡                            REPLY           write              ‡
  4582. ‡                            PHONE           talk               ‡
  4583. ‡                            DECnet          ftp                ‡
  4584. ‡                                            telnet             ‡
  4585. ‡                                                               ‡
  4586. ‡Compilers                   FORTRAN         f77                ‡
  4587. ‡                                            cc                 ‡
  4588. ‡                                                               ‡
  4589. ‡Text Processing             RUNOFF          troff              ‡
  4590. ‡                                            nroff              ‡
  4591. ‡                                            awk                ‡
  4592. ‡                                            lex                ‡
  4593. ‡                                                               ‡
  4594. ‡                                            sed                ‡
  4595. ‡                                                               ‡
  4596. ‡                            SORT            sort               ‡
  4597. ‡                            MERGE           merge              ‡
  4598. ‡                                                               ‡
  4599. ‡Program Development         LINK            link               ‡
  4600. ‡Tools                       DEBUG           adb/dbx            ‡
  4601. ‡                            LIBRARIAN       ar/ranlib          ‡
  4602. ‡                            DEC MMS         make               ‡
  4603. ‡                                            yacc               ‡
  4604. ‡                            DEC CMS         scs                ‡
  4605. ‡                                                               ‡
  4606. ‡Miscellaneous               DECalc          bc/dc              ‡
  4607. ‡                            DECspell        spell              ‡
  4608. ‡                                                               ‡
  4609. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4610.  
  4611. As you can see from the above lists, both systems offer editors
  4612. capable of screen or line editing capabilities. Both have
  4613. interactive communications, electronic mail, networking, file
  4614. transfer, remote command execution, and remote logins. These
  4615. utilities and tools are standard to UNIX but require a license to
  4616. run under VMS. The Digital Command Language (DCL) and the UNIX
  4617. Shell (Bourne,C, or Korn) are command interpreters. That is, they
  4618. are both programs that parse the command line and then pass control
  4619. to other programs that are the kernel of the operating system.
  4620. 7.1  Processes
  4621.  
  4622. When you login to either system the operating system will create
  4623. a unique process. This process is given access to memory and CPU
  4624. resources. The differences between the two operating systems with
  4625. respect to multi-tasking needs explanation. Multi-tasking is
  4626. concurrent processes initiated by a single user. When the user
  4627. starts a terminal session the system initiates a single process
  4628. called the PARENT process. It is possible to start multiple
  4629. processes from the parent process. This is called spawning in VMS
  4630. and forking in UNIX.  The new process is called a sub-process in
  4631. VMS and a child process in UNIX. This idea of "forking" a child
  4632. process occurs frequently in UNIX. 
  4633.  
  4634. When UNIX creates a child process or VMS creates a subprocess
  4635. different things occur. First, let's look at VMS. When the
  4636. subprocess is spawned the parent goes to "sleep" until the user
  4637. logs off from the subprocess. When the logoff occurs control
  4638. returns to the parent. The VMS ATTACH command gives control back
  4639. to the parent process and the subprocess goes to sleep. The point
  4640. is that only one process is active at a time. The exception is the
  4641. VMS RUN/PROCESS=name which will run a user-defined process at the
  4642. same time commands can be issued at the parent process.
  4643.  
  4644. In UNIX, you can run parent and children processes at the same
  4645. time. A child process can fork another process and thus a process
  4646. can be both a parent and child. Child processes are not restricted
  4647. to user-defined images but can be any valid UNIX operation. UNIX
  4648. processes that are running or stopped but not getting input from
  4649. a terminal are said to be in background. When you begin a UNIX
  4650. session the kernel gives you a copy of the shell. When you enter
  4651. a command the Shell forks a child. That child then processes the
  4652. command you entered.
  4653.  
  4654.  Note: some commands are executed by the Shell itself and no child
  4655. is forked.
  4656.           
  4657. This is a different concept from VMS, in which all commands are
  4658. executed  by the parent process. Once a subprocess is created the
  4659. parent remains dormant until the subprocess completes.
  4660.  
  4661. All the above parent and child processes use the standard default
  4662. for input and output devices, the terminal. Input and output
  4663. streams in UNIX are called standard input (stdin) and standard
  4664. output (stdout). Standard error (stderr) also uses the terminal as
  4665. it's default output.  In order to redirect these streams from a
  4666. terminal in VMS it is requires the assignment of the logical names
  4667. SYS$OUTPUT, SYS$INPUT, and SYS$ERROR to a file or device. UNIX has
  4668. a much nicer means of redirecting the input or output.
  4669.  
  4670. 7.2  Pipes
  4671.  
  4672. A vertical bar (|) is used to redirect the output of a command to
  4673. the input of another command. This is the power of UNIX. For
  4674. example, we want to get a list of all currently active users,
  4675. sorted in alphabetical order, and sent to the printer, how could
  4676. that be done in VMS? Here's one solution:
  4677.  
  4678. VMS Sample Session:
  4679.  
  4680. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4681. ‡$SHOW USERS/OUTPUT=A.TEMP                                      ‡
  4682. ‡$SORT/KEY=POSITION:40,SIZE:6)-                                 ‡
  4683. ‡  A.TEMP SYS$PRINT                                             ‡
  4684. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4685.  
  4686. Notice the need for an intermediate file called A.TEMP.
  4687.  
  4688. Now how would this same requirement be met using UNIX. There is a
  4689. command that will list the users that are currently logged on to
  4690. the system. The command is who. Pipes allow the output of one
  4691. command to be the input into another command. The output of who
  4692. can be put into another UNIX command sort by a pipe. In a similar
  4693. manner, the output of sort can be redirected to another command
  4694. called lp. Thus the same problem can be solved using UNIX Shell in
  4695. this way:
  4696.  
  4697. UNIX Bourne Shell Sample Session:
  4698.  
  4699. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4700. ‡$who | sort | lp -dmtlzr                                       ‡
  4701. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4702.  
  4703. Notice that there is not a one-to-one command conversion that is
  4704. taking place here. The idea is to convert the process more than
  4705. individual commands from VMS DCL to UNIX Shell.
  4706. 7.3  Input, Output, and Error Redirection
  4707.  
  4708. Just as the VMS logicals SYS$INPUT, SYS$OUTPUT, SYS$COMMAND, and
  4709. SYS$ERROR point at the terminal by default, so do the UNIX
  4710. equivalents stdin, stdout, and stderr. The equivalent of the
  4711. SYS$COMMAND in UNIX is the "Here is" document. UNIX uses a much
  4712. more simplified method of redirecting input and output to or from
  4713. a file. UNIX does not require the effect of an ASSIGN statement
  4714. ahead of the redirection. UNIX uses a metacharacter that is
  4715. included as part of the command line. Here is an example of both
  4716. VMS and UNIX.
  4717.  
  4718. VMS Sample Session:
  4719.  
  4720. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4721. ‡$ASSIGN/USER A.LIS SYS$OUTPUT                                  ‡
  4722. ‡$ASSIGN/USER INPUT.DAT FOR005                                  ‡
  4723. ‡$RUN MYPROG                                                    ‡
  4724. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4725.                                                                  
  4726. The equivalent function can be written in UNIX Shell like this:
  4727.  
  4728. UNIX Bourne Shell Sample:
  4729.  
  4730. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4731. ‡$myprog < input.dat > a.lis                                    ‡
  4732. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4733.                                                                  
  4734. The point here is to see that the metacharacters < and > act as
  4735. the input and output redirection symbols. Please don't get the idea 
  4736. that UNIX is much simpler than VMS DCL. That is not the case. They
  4737. each have strong points and weak points, they are not the same.
  4738. This is comparing apples and oranges. 
  4739.  
  4740. Here is a partial list of the metacharacters used by the UNIX
  4741. Shells and their meanings. These can be useful when you try to
  4742. redirect input and output.
  4743. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4744. ‡Character      Meaning                                         ‡
  4745. ˆ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜·
  4746. ‡>        Redirect standard output (stdout)                     ‡
  4747. ‡                                                               ‡
  4748. ‡>>       Redirect and append standard output (stdout)          ‡
  4749. ‡                                                               ‡
  4750. ‡>&       Redirect standard output (stdout) and standard error  ‡
  4751. ‡         (stderr)                                              ‡
  4752. ‡                                                               ‡
  4753. ‡>>&      Redirect and append standard output (stdout) and      ‡
  4754. ‡         standard error (stderr)                               ‡
  4755. ‡                                                               ‡
  4756. ‡<        Redirect standard input (stdin)                       ‡
  4757. ‡                                                               ‡
  4758. ‡|        Redirect standard output (stdout) to another          ‡
  4759. ‡         command                                               ‡
  4760. ‡                                                               ‡
  4761. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4762.  
  4763. These are the most commonly used redirection metacharacters.
  4764.  
  4765. Notes:
  4766.  
  4767.      UNIX redirection only affects the command line on which the
  4768.      redirection character occurs.
  4769.  
  4770.      Error messages are not redirected and will appear on the
  4771.      terminal.
  4772.  
  4773.      If a file already exists, VMS will create a new version of
  4774.      the file with a higher version number. By default, UNIX will
  4775.      overwrite the existing file.
  4776. 7.4  Command Structure and File Naming Conventions
  4777.  
  4778. VMS is not case-sensitive in its interpretation of commands. It
  4779. doesn't distinguish between upper and lower case characters. This
  4780. is not true in UNIX, however. Commands must be entered in lower
  4781. case characters only. The Shell will not understand characters that
  4782. are in uppercase.
  4783.  
  4784. Filenames are also case sensitive in UNIX. The file named
  4785. MYFILE.DAT and the file myfile.dat refer to different files. One
  4786. advantage of this is that you can have a much larger variety of
  4787. filenames with fewer characters. Especially good if you don't like
  4788. to type.
  4789.  
  4790.  
  4791. This also has advantage over the filename conventions used by VMS.
  4792. Directories and subdirectories are pointer files in both operating
  4793. systems. When a subdirectory is created in VMS it is given the
  4794. extension name .DIR automatically. UNIX files on the other hand do
  4795. not distinguish between ordinary files and directories. Many VMS
  4796. users have adopted a practice of naming new subdirectories in UNIX
  4797. with all capital letters or the first letter being capitalized.
  4798. This is not, however, standard UNIX practice.
  4799.  
  4800. VMS Sample Session:
  4801.  
  4802. .................................................................
  4803. .  $CREATE/DIRECTORY [.TEST]                                    .
  4804. .  $DIRECTORY                                                   .
  4805. .................................................................
  4806.                                 
  4807. UNIX Shell Sample Session:      
  4808.                                 
  4809. .................................................................
  4810. .  $mkdir Test                                                  .
  4811. .  $ls Test                                                     .
  4812. .................................................................
  4813.  
  4814. It is possible in UNIX to maintain the same filename conventions
  4815. that you used in VMS. The period (.) is a legal character in a UNIX
  4816. filename. Some VMS users like to continue the practice of naming
  4817. files using the same . extensions from VMS. Problems occur when
  4818. default extensions are different between the two systems. For
  4819. example, object files use the extension .OBJ in VMS but .o in UNIX.
  4820. Another example is FORTRAN source code in UNIX the extension is .f
  4821. and VMS uses .FOR. Note that .o and .f are UNIX conventions to
  4822. facilitate file recognition and that UNIX commands do not assume
  4823. file extensions as VMS does.
  4824. Here is a list of commonly used extensions for both operating
  4825. systems.
  4826.                                                          
  4827. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4828. ‡VMS        UNIX    Definition                                  ‡
  4829. ‡                                                               ‡
  4830. ˆ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜·
  4831. ‡.OLB       .a      Library                                     ‡
  4832. ‡                                                               ‡
  4833. ‡.BAS       .bas    BASIC Source Code                           ‡
  4834. ‡                                                               ‡
  4835. ‡.C         .c      C Source Code                               ‡
  4836. ‡                                                               ‡
  4837. ‡.FOR       .f      FORTRAN Source Code                         ‡
  4838. ‡           .h      C header files                              ‡
  4839. ‡           .l      lex program                                 ‡
  4840. ‡                                                               ‡
  4841. ‡.OBJ       .o      Object Code                                 ‡
  4842. ‡                                                               ‡
  4843. ‡.PAS       .p      PASCAL Source Code                          ‡
  4844. ‡           .s      Symbolic Assembly Code                      ‡
  4845. ‡           .y      yacc program                                ‡
  4846. ‡                                                               ‡
  4847. ‡.EXE        a.out  Executable Image                            ‡
  4848. ‡                                                               ‡
  4849. ‡.ADA               ADA Source Code                             ‡
  4850. ‡.B32               BLISS-32 Source Code                        ‡
  4851. ‡.CLD               Command description file                    ‡
  4852. ‡.COB               Cobol Source Code                           ‡
  4853. ‡.COM               Commands for the language interpreter       ‡
  4854. ‡.DAT               Data file                                   ‡
  4855. ‡.DIS               Distribution list file for MAIL             ‡
  4856. ‡.DIR               Directory file                              ‡
  4857. ‡.EDT               Startup command file for EDT editor         ‡
  4858. ‡.DOC               Documentation                               ‡
  4859. ‡.HLP               Input source files for HELP Library         ‡
  4860. ‡.JOU               Journal file created by EDT                 ‡
  4861. ‡.LIS               Listing of text                             ‡
  4862. ‡.LOG               Batch job output file                       ‡
  4863. ‡.MAI               MAIL message file                           ‡
  4864. ‡.MAR               VAX Macro source code                       ‡
  4865. ‡.SYS               System Image                                ‡
  4866. ‡.TMP               Temporary file                              ‡
  4867. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  4868. 7.5  File Management Commands
  4869.  
  4870. This is a table of the more commonly used file management commands.
  4871. Some of these commands have been covered elsewhere in this manual.
  4872. The on-line manual command (man) can be used to get detailed
  4873. information about any UNIX command.
  4874.  
  4875.      UNIX           VMS            Purpose
  4876.      Command        equivalent
  4877.  
  4878.      ar             LIBRARY        Archive files
  4879.  
  4880.      awk            TPU            Pattern matching utility
  4881.  
  4882.      cat            TYPE/APPEND    Catenates and prints to       
  4883.                                    terminal
  4884.  
  4885.      cd             SET DEFAULT    Change working directory
  4886.  
  4887.      chgrp          SET FILE       Change group ownership
  4888.  
  4889.      chmod          SET PROTECTION Changes protection
  4890.  
  4891.      cmp            DIFFERENCE     Compares two files and reports
  4892.                                    first difference found
  4893.  
  4894.      cp             COPY           Create a new copy
  4895.  
  4896.      find           DIRECTORY      Locates within a directory 
  4897.                                    structure
  4898.  
  4899.      ftp            COPY           Transfer to/from remote node
  4900.  
  4901.      grep           SEARCH         Finds a string
  4902.  
  4903.      ln             ASSIGN         Create a symbolic link
  4904.  
  4905.      ls             DIRECTORY      List contents of a directory
  4906.  
  4907.      merge          MERGE          Merge files
  4908.  
  4909.      mkdir          CREATE/DIR     Make a directory
  4910.  
  4911.      mv             RENAME         Moves or renames files
  4912.  
  4913.      od             DUMP           Octal, decimal, hex, ASCII
  4914.                                    dump
  4915.  
  4916.      pr             PRINT/HEAD     Prints files
  4917.  
  4918.      pwd            SHOW DEFAULT   Working directory name
  4919.  
  4920.      rm             DELETE         Removes or deletes files
  4921.  
  4922.     rmdir           DELETE         Removes a directory file
  4923.  
  4924.     sort            SORT           Sorts by a key
  4925.  
  4926.     tail            EDIT/READ      Outputs last part of file
  4927.  
  4928.     tar             BACKUP         Tape archive
  4929.  
  4930.     touch           CREATE         Updates file characteristics
  4931.                                    or creates null file
  4932.  
  4933.     tr              EDIT           Translates characters
  4934.      
  4935. 7.6  Metacharacters
  4936.  
  4937. Characters that have special meanings to the Shell are known as
  4938. metacharacters. Users should avoid using these characters in
  4939. filenames as results might be unpredictable. We have already seen
  4940. several metacharacters, for example, vertical bar (|), or the
  4941. greater than (>) or less than (<). The function of metacharacters
  4942. can be different depending on whether the Shell or a UNIX tool
  4943. interprets the character. The following is a list of UNIX special
  4944. characters and their VMS equivalent.
  4945.  
  4946.  UNIX         Function                            VMS equivalent
  4947.  Char
  4948.  
  4949.  &   Perform command in Background
  4950.  =   Assignment operator                               =
  4951.  ;   Command separator
  4952.  \   Continuation of command line                      -
  4953.  \m  Literal translation of metacharacter m            "m
  4954.  '   Turn off special meaning                          "
  4955.  `   Process immediately                               @ & run
  4956.  "   Group characters into a single argument           "
  4957.  #   Comment follows                                   !
  4958.  *   Wildcard filename substitution                    *
  4959.  ?   Wildcard filename substitution single character   %
  4960.  $   Argument substitution follows                     '
  4961.  $#  Argument count
  4962.  $$  Process id                              F$GETJPI("PID")
  4963.  $?  Exit status                                  $STATUS
  4964.  $<  Read one line from standard input            INQUIRE, READ
  4965.  .   Current directory                                []
  4966.  []  Selective filename substitution
  4967.  
  4968. Note: Metacharacters unique to the C-Shell have not been included
  4969. in this list to reduce confusion. Check C-Shell documentation for
  4970. a complete list.
  4971.  
  4972. 7.7  Wildcards: Are They Really Wild?
  4973.  
  4974. UNIX wildcards extend the features found with wildcards in VMS.
  4975. The following table shows how UNIX expands wildcard definitions:
  4976.  
  4977. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  4978. ‡UNIX example                   Meaning                         ‡
  4979. ˆ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜·
  4980. ‡                                                               ‡
  4981. ‡ *             # All files in the current directory and one    ‡
  4982. ‡                 level below                                   ‡
  4983. ‡                                                               ‡
  4984. ‡ .             # Files in the current directory                ‡
  4985. ‡                                                               ‡
  4986. ‡                                                               ‡
  4987. ‡ *.*           # All files that contain a period in the        ‡
  4988. ‡                 filename                                      ‡
  4989. ‡                                                               ‡
  4990. ‡ *.com         # All files in the current directory that       ‡
  4991. ‡                 end in .com                                   ‡
  4992. ‡                                                               ‡
  4993. ‡ ?.com         # All files in the current directory that       ‡
  4994. ‡                 end in .com and have one character            ‡
  4995. ‡                 preceding the period                          ‡
  4996. ‡                                                               ‡
  4997. ‡ name[xyz]     # All files in the current directory, namex,    ‡
  4998. ‡                 namey, or namez                               ‡
  4999. ‡                                                               ‡
  5000. ‡ name[a-z]     # All files in the current directory namea      ‡
  5001. ‡                 through namez                                 ‡
  5002. ‡                                                               ‡
  5003. ‡ name[a-z4]    # All files in the current directory, namea     ‡
  5004. ‡                 through namez and name4                       ‡
  5005. ‡                                                               ‡
  5006. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5007.                                                                
  5008. There are no absolute rules concerning the use of wildcards. The
  5009. output produced by the wildcard expansion process is command 
  5010. dependent. For instance, the ls * command will list files in the
  5011. current directory and the files in the directory in the next lower
  5012. level as well. The wc * (word count) command will produce output
  5013. for the files in the current directory only. Thus as you can see
  5014. commands vary in how wildcards are expanded.
  5015.  
  5016. Users and programmers can use wildcards in a similar way to the
  5017. method of using wildcards on the VAX. UNIX will interpret *.com to
  5018. mean any file in the current directory that ends in .com even
  5019. though the extension has no meaning in UNIX. 
  5020. 7.8  Summary
  5021.  
  5022. The VMS and UNIX operating systems are similar in some respects.
  5023. The VMS user must recognize that there are some fundamental
  5024. differences. 
  5025.  
  5026. UNIX allows multiple processes and the user must learn to manage
  5027. these processes. VMS usually manages a single process which
  5028. processes commands in sequence.
  5029.  
  5030. UNIX has a different command syntax. UNIX commands are already
  5031. short and cannot be abbreviated like VMS commands. UNIX commands
  5032. do not lend themselves easily to describe their function. For
  5033. example, TYPE seems to describe the function better than cat in
  5034. UNIX. Single letter options modify UNIX commands in a manner
  5035. similar to VMS command qualifiers.
  5036.  
  5037. UNIX has a different file and directory structure. You can address
  5038. any file irrespective of the physical device using the absolute or
  5039. relative pathname.
  5040.  
  5041. UNIX has metacharacters which have special functions when
  5042. interpreted by the Shell.
  5043.                                NOTES
  5044. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  5045. Workshop 7
  5046.  
  5047. This workshop will reinforce your understanding of the ideas
  5048. presented in all the previous chapters. Login to the Multimax using
  5049. the username and password given to you by the instructor.  Each
  5050. student is to complete the entire workshop.
  5051.  
  5052. DESK EXERCISES
  5053.  
  5054.      1.   Convert the DCL command file found on the next page
  5055.           to BourneShell and run it.
  5056.  
  5057.  
  5058.      Helpful??  Hints:
  5059.  
  5060.  
  5061.           What does the VMS DCL command file do?  
  5062.  
  5063.           Does UNIX Shell have a similar function? 
  5064.  
  5065.           What does the UNIX command cut do?
  5066.  
  5067.           What does the UNIX command date do?
  5068.  
  5069.           Can this script be converted one line at a time?
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.                      Continue on the next page
  5086.  
  5087. $ Today = F$cvtime("today",,"weekday")
  5088. $ if today .eqs. "Monday" then goto monday
  5089. $ if today .eqs. "Tuesday" then goto tuesday
  5090. $ if today .eqs. "Wednesday" then goto wednesday
  5091. $ if today .eqs. "Thursday" then goto thursday
  5092. $ if today .eqs. "Friday" then goto friday
  5093. $ go to weekend
  5094. $ Monday:
  5095. $    Write sys$output " "
  5096. $    Write sys$output "Today is ''today' and there are 5 days    
  5097.  until this weekend"
  5098. $    Write sys$output " "
  5099. $    exit
  5100. $ Tuesday:
  5101. $    Write sys$output " "
  5102. $    Write sys$output "Today is ''today' and there are 4 days    
  5103.  until this weekend"
  5104. $    Write sys$output " "
  5105. $    exit
  5106. $ Wednesday:
  5107. $    Write sys$output " "
  5108. $    Write sys$output "Today is ''today' and there are 3 days    
  5109.  until this weekend"
  5110. $    Write sys$output " "
  5111. $    exit
  5112. $ Thursday:
  5113. $    Write sys$output " "
  5114. $    Write sys$output "Today is ''today' and there are 2 days    
  5115.  until this weekend"
  5116. $    Write sys$output " "
  5117. $    exit
  5118. $ Friday:
  5119. $    Write sys$output " "
  5120. $    Write sys$output "Today is ''today' and there is 1 day 
  5121.  until this weekend"
  5122. $    Write sys$output " "
  5123. $    exit
  5124. $ Weekend:
  5125. $    Write sys$output " "
  5126. $    Write sys$output "Today is ''today' and why are you working
  5127.  on a weekend"
  5128. $    Write sys$output " "
  5129. $    exit
  5130.  
  5131.   
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.                      Continue on the next page
  5138.      2.   Not all functions, especially calls to library         
  5139.           functions, that exist in VMS have an equivalent call in
  5140.           UNIX Shell. An example of this is F$ELEMENT in VMS. 
  5141.           Write a BourneShell script that will do the same job as
  5142.           F$ELEMENT and test it.
  5143.  
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.          If time remains and you want a further challenge:
  5153.  
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.      3.   Write a user interface to add and delete records to the
  5161.           phone.lis database. Query the user in a user friendly
  5162.           manner and check to see if the name is already in the
  5163.           database prior to adding it.
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.           That's all for this workshop. If you didn't finish
  5171.           because of time, that's OK, as long as you understand
  5172.           the process needed to do conversions.
  5173.                                NOTES
  5174. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  5175. 8.  ADVANCED FEATURES OF FTP
  5176.  
  5177.  
  5178. This chapter will discuss some advanced features of the FTP server
  5179. as implemented on the Multimax.  The introduction of FTP in UNIX
  5180. for Beginning Users gave an elementary introduction to some of the
  5181. features.  If you are not familiar with the basics, please refer
  5182. to that manual.  It is not the purpose to review those basics here.
  5183.  
  5184. The FTP (Internet file transfer program) is the user interface to
  5185. the DARPA File Transfer Protocol.  This utility program will
  5186. transfer files to and from a remote computer.  In order for files
  5187. to be transferred from the local computer to a remote computer, a
  5188. connection must be established.  This can be done from the FTP
  5189. command line.  The connection to the remote computer will remain
  5190. active until it is terminated by the user.
  5191.  
  5192. The remote computer with whom the connection is to be made can be
  5193. specified on the FTP command.  In this case, FTP will immediately
  5194. try to establish a connection.  If the remote computer is not
  5195. specified, FTP will enter its command interpreter mode and wait
  5196. for instructions; a prompt will be displayed.
  5197.  
  5198. FTP does have a help feature, and all 58 commands can be listed.
  5199. It will also give a terse description of each command.  In
  5200. addition, there are on-line manual pages which can be accessed by
  5201. using the man command in UMAX.
  5202. 8.1  Initializing FTP on UMAX
  5203.  
  5204.  
  5205. The term, "local computer," will refer to the Multimax.  The
  5206. "remote computer" will refer to the other computer with which you
  5207. are trying to send/receive files.  For purposes of this course, we
  5208. will be referring to the VAX minicomputer as the remote computer.
  5209. Please be aware that these procedures will work for any computer
  5210. connected to Ethernet and having an FTP server.
  5211.  
  5212. FTP can be invoked on the local computer using the following
  5213. syntax:
  5214.  
  5215. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5216. ”  Command Format:  ftp [-v] [-d] [-i] [-n] [-g] [host]         ”
  5217. ”                                                               ”
  5218. ”         -v = verbose on, forces ftp to show all responses     ”
  5219. ”              from the remote server                           ”
  5220. ”                                                               ”
  5221. ”         -d = enables debugging                                ”
  5222. ”                                                               ”
  5223. ”         -i = turn off interactive prompting during            ”
  5224. ”              multiple file transfers.                         ”
  5225. ”                                                               ”
  5226. ”         -n = disables the "auto-login" feature                ”
  5227. ”                                                               ”
  5228. ”         -g = disable filename globbing                        ”
  5229. ”                                                               ”
  5230. ”         host = the name of the remote computer                ”
  5231. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5232.  
  5233. NOTE:     UMAX (UNIX) is case sensitive.  The commands and options
  5234.           must be entered as shown. 
  5235. 8.2  Multiple File Transfers
  5236.  
  5237.  
  5238. The syntax for the multiple get command is:
  5239.  
  5240. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5241. ”  Command Format:  mget remote-files                           ”
  5242. ”                                                               ”
  5243. ”  remote-files = remote computer wildcard specification        ”
  5244. ”                      or                                       ”
  5245. ”                 file1 file2 ... filen                         ”
  5246. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5247.  
  5248. The remote computer wildcard specification is expanded in a process
  5249. called globbing.  Once the globbing is complete, a get is performed
  5250. on each filename; and it is  transferred to the local computer. 
  5251. The filename is the same on both computers.  You can specify the
  5252. filenames to be transferred separating them with spaces.
  5253.  
  5254. Example:
  5255. .................................................................
  5256. . ftp>mget *.dat;*                                              .
  5257. .................................................................
  5258.  
  5259.  
  5260. This command will transfer all versions of the remote-files that
  5261. have the filename extension of .dat.  If the option -i was
  5262. specified on the call to FTP, then the files will be transferred
  5263. automatically.  If the option was not specified, FTP will prompt
  5264. you before transferring each file.
  5265.  
  5266. Sample Session:
  5267.  
  5268. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5269. ‡ ftp>mget *.dat                                                ‡
  5270. ‡ mget change_pass.dat;1?                                       ‡
  5271. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5272.  
  5273.  
  5274. The default is 'yes', pressing (Ret) will cause the file to be sent
  5275. to the local directory.  If you don't want this file transferred,
  5276. enter n(Ret); you will then be prompted for the next file, if one
  5277. exists.
  5278. 8.3  Auto Login Feature
  5279.  
  5280.  
  5281. It is possible to have the login procedure occur automatically. 
  5282. To do this requires a file in your home directory called .netrc.
  5283. The .netrc file contains login and initialization information to
  5284. be used by the auto-login process.  The following variables are
  5285. used and can be separated by spaces, tabs, or new lines.
  5286.  
  5287.  
  5288. machine name  
  5289.  
  5290. This is the name of the remote computer.  The auto-login process
  5291. will search the .netrc file for a machine variable that matches
  5292. the name of the remote computer on the ftp command or as an open
  5293. command argument.  Once a match is found, the next variables are
  5294. also processed until the end of file or another machine variable
  5295. is encountered.
  5296.  
  5297.  
  5298. login name
  5299.  
  5300. This is the username on the remote system.  If this variable is
  5301. present, the auto-login process will login to the remote computer
  5302. with the given username.
  5303.  
  5304.  
  5305. password string
  5306.  
  5307. This is the password to be used when logging in to the remote
  5308. system.
  5309.  
  5310. NOTE:     If this variable is present in the .netrc file, ftp will
  5311.           abort the auto-login process if the .netrc file is
  5312.           readable by anyone but the user.
  5313.  
  5314.  
  5315. account string
  5316.  
  5317. This supplies an additional account password.  If present, the
  5318. auto-login process will supply the string as an additional password
  5319. if required by the remote server.
  5320.  
  5321.  
  5322. macdef name
  5323.  
  5324. This defines a macro.  This variable will function like the ftp
  5325. macdef command.  A macro is defined with the specified name, its
  5326. contents begin with the next .netrc line and continue until a null
  5327. line (2 new line characters).  If a macro named init is defined,
  5328. it will be executed as the last step of the auto-login process.
  5329. Sample Session:
  5330.  
  5331. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5332. ‡ $cat .netrc                                                   ‡
  5333. ‡ machine erc830                                                ‡
  5334. ‡ login teacher                                                 ‡
  5335. ‡ password secret1                                              ‡
  5336. ‡ machine erc780                                                ‡
  5337. ‡ login rharding                                                ‡
  5338. ‡ password secret2                                              ‡
  5339. ‡ $                                                             ‡
  5340. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5341.  
  5342. To invoke the auto-login feature, type the ftp command and enter
  5343. the name of the remote computer as an argument.
  5344.  
  5345. Sample Session:
  5346.  
  5347. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5348. ‡ $ftp erc830                                                   ‡
  5349. ‡ Connected to erc830.                                          ‡
  5350. ‡ 220 erc830 Wollongong FTP Server (Ver 5.0) at Tue Oct 23      ‡
  5351. ‡ 331 Password required for rharding.                           ‡
  5352. ‡ 230 User logged in, default directory D_1131:[RHARDING]       ‡
  5353. ‡ ftp>                                                          ‡
  5354. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5355.  
  5356. If the .netrc file is readable by anyone other than the user, the
  5357. following error message will appear; and the connection will not
  5358. be made to the remote computer.
  5359.  
  5360. Sample Session:
  5361.  
  5362. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5363. ‡ $ls -l .netrc                                                 ‡
  5364. ‡ $ftp erc830                                                   ‡
  5365. ‡ Connected to erc830.                                          ‡
  5366. ‡ 220 erc830 Wollongong FTP Server (Ver 5.0) at Tue Oct 23      ‡
  5367. ‡ Error - .netrc file not correct mode.                         ‡
  5368. ‡ Remove password or correct code.                              ‡
  5369. ‡ 221 Goodbye.                                                  ‡
  5370. ‡ ftp>                                                          ‡
  5371. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5372.  
  5373. To correct this error, change the mode of the .netrc file so it is
  5374. not readable by other users or remove the password from the file.
  5375. This is to prevent your password from being read by an unauthorized
  5376. user.
  5377. 8.4  Macros
  5378.  
  5379.  
  5380. Macros are a single instruction that a program replaces by several,
  5381. usually, more complex instructions.  The ftp command to create a
  5382. macro definition is:
  5383.  
  5384. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5385. ”  Command Format:  macdef macro-name                           ”
  5386. ”                                                               ”
  5387. ”  macro-name - the name of the macro                           ”
  5388. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5389.  
  5390. After the macdef command is given, all subsequent lines are stored
  5391. as a macro with the name macro_def.  Consecutive newline characters
  5392. or carriage returns terminate the input mode into the macro.  There
  5393. is a limit of 16 defined macros and a limit of 4096 characters in
  5394. all defined macros.
  5395.  
  5396. Sample Session:
  5397.  
  5398. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5399. ‡ ftp>macdef get_files                                          ‡
  5400. ‡ open erc780                                                   ‡
  5401. ‡ get file_1                                                    ‡
  5402. ‡ put result_2                                                  ‡
  5403. ‡ close                                                         ‡
  5404. ‡ ftp>                                                          ‡
  5405. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5406.  
  5407. In this example, the four lines of the macro can be executed simply
  5408. be entering get_files at the ftp prompt.  The macro will only exist
  5409. until the current ftp session is closed.
  5410. 8.5  Filename Translation
  5411.  
  5412.  
  5413. Filename conventions differ from one computer to another, and FTP
  5414. will allow you to translate the name as it is transferred.  One
  5415. way is to specify the name of the file as it is to exist on the
  5416. local computer.  This is done by the argument on the put or get
  5417. command.
  5418.  
  5419. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5420. ”  Command Format:  put local-file [remote-file]                ”
  5421. ”                                                               ”
  5422. ”                   get remote-file [local-file]                ”
  5423. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5424.  
  5425.  
  5426. If you don't specify the remote-file (for the put command) or the
  5427. local-file (for the get command), the name will be the same on both
  5428. the local and remote computer.  This can cause a problem if you are
  5429. not aware of it.  There is an FTP command that will allow
  5430. the name to be translated automatically.
  5431.  
  5432. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5433. ”  Command Format:  nmap [inpattern outpattern]                 ”
  5434. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5435.  
  5436.  
  5437. If no arguments are supplied, it will set or unset the filename
  5438. mapping mechanism.  If arguments are specified, remote filenames
  5439. are mapped during mput (multiple file puts) and put (single file)
  5440. commands that are issued without a specified remote filename.
  5441.  
  5442. If arguments are specified, local filenames are mapped during mget
  5443. (multiple file gets) and get (single file) commands that are issued
  5444. without a specified local filename.
  5445.  
  5446. The mapping follows the pattern set by inpattern and outpattern.
  5447. Variable templating is done by including the sequences "$1",
  5448. "$2",...."$9 "in inpattern.  All other characters are treated
  5449. literally and are used to determine the nmap inpattern variable
  5450. values.
  5451.  
  5452. For example, say the inpattern was $1.$2 and the remote filename
  5453. is mydata.data, $1 would have the value mydata and $2 would have
  5454. the value data.  The outpattern determines the resulting mapped
  5455. filename.  The sequences "$1", "$2",..."$9", are replaced by the
  5456. value resulting from the inpattern template.  "$0" is replaced by
  5457. the original filename.
  5458. 8.6  Aborting Transfers
  5459.  
  5460.  
  5461. Press the terminal interrupt key (usually Ctrl-C) to abort a file
  5462. transfer.  The sending transfer will stop immediately.  Receiving
  5463. transfers will be halted by FTP sending an ABOR command to the
  5464. remote server and discarding any further data that is received.
  5465.  
  5466.  
  5467. If the remote server doesn't support the ABOR protocol command the
  5468. ftp> prompt will not appear until the requested file has been sent.
  5469. 8.7  More Remote Computer Commands
  5470.  
  5471. These commands can be useful when working with the directories on
  5472. the remote computer.
  5473.  
  5474. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5475. ”  Command Format:  cdup                                        ”
  5476. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5477.  
  5478. This FTP command will change the remote machine current working
  5479. directory to the parent of the current working directory.
  5480.  
  5481.  
  5482. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5483. ”  Command Format:  delete remote-file                          ”
  5484. ”                                                               ”
  5485. ”  remote-file  name of the file to delete                      ”
  5486. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5487.  
  5488. This FTP command will delete the specified file.
  5489.  
  5490.  
  5491. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5492. ”  Command Format:  mdelete [remote-files]                      ”
  5493. ”                                                               ”
  5494. ”  remote-files  names of the files to delete                   ”
  5495. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5496.                                                                  
  5497. This FTP command acts as a multiple delete.  It will delete all
  5498. the specified files.
  5499.  
  5500.  
  5501. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5502. ”  Command Format:  mkdir directory-name                        ”
  5503. ”                                                               ”
  5504. ”  directory-name  the name of the directory to be created      ”
  5505. ”                  on the remote computer.                      ”
  5506. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5507.                                                                  
  5508. This FTP command will create a directory on the remote computer.
  5509.  
  5510.  
  5511. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5512. ”  Command Format:  rmdir directory-name                        ”
  5513. ”                                                               ”
  5514. ”  directory-name  the name of the directory on the remote      ”
  5515. ”                  computer that will be removed.               ”
  5516. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5517.  
  5518. This FTP command will remove the specified directory.
  5519.  
  5520. NOTE:     This command will not work with some remote servers.
  5521.                                NOTES
  5522. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  5523. Workshop 8
  5524.  
  5525. This workshop will reinforce your understanding of the ideas
  5526. presented in Chapter 9. Login to the Multimax using the username
  5527. and password given to you by the instructor.  Each student is to
  5528. complete the entire workshop.
  5529.  
  5530. DESK EXERCISES (10 minutes)
  5531.  
  5532.  
  5533.      1.   What FTP command is used to transfer more than one file
  5534.           at a time? What FTP command will give a prompt to you
  5535.           before each file is retrieved? Suggestion: there are two
  5536.           ways
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542.      2.   What is the name of the file where the auto-login
  5543.           variables are found?  Extra credit: Why does this file
  5544.           begin with a dot (.)? 
  5545.  
  5546.  
  5547.  
  5548.  
  5549.  
  5550.      3.   How can the file in question the auto-login file be
  5551.           protected from unauthorized reading?
  5552.  
  5553.  
  5554.  
  5555.  
  5556.  
  5557.      4.   What do the following FTP commands do?
  5558.  
  5559.  
  5560.           cdup
  5561.  
  5562.  
  5563.           delete (tough question)
  5564.  
  5565.  
  5566.           mdelete (ditto)
  5567.  
  5568.  
  5569.           mkdir
  5570.  
  5571.  
  5572.           rmdir
  5573.  
  5574.                      Continue on the next page
  5575. COMPUTER EXERCISES (30 minutes)
  5576.  
  5577.  
  5578.      5.   Transfer all the files from on the VAX (erc830) to the
  5579.           domax1. Use only one command and use wildcards. The
  5580.           username and password for the VAX will be given to you
  5581.           by the instructor. 
  5582.  
  5583.  
  5584.  
  5585.  
  5586.  
  5587.      6.   Transfer the files from the VAX and this time translate
  5588.           the names of the files as they are transferred.
  5589.  
  5590.  
  5591.  
  5592.  
  5593.  
  5594.      7.   Create an auto-login file for the erc830 and
  5595.           then do an auto-login to the VAX.
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601.      8.   Logout.
  5602. 9.  OPTIONAL CHAPTER - KORNSHELL PROGRAMMING
  5603.  
  5604.  
  5605. The KornShell is a command-programming language that executes
  5606. commands read from a terminal or file.  The KornShell is close to
  5607. being upward compatible with the standard BourneShell.  For
  5608. example, scripts written for the BourneShell (sh) will also work
  5609. in the KornShell (ksh).  The major enhancements are command-line
  5610. reentry, in-line command editing, and aliasing.
  5611.  
  5612. This chapter will deal with some, not all, of the features that
  5613. differentiate it from the BourneShell.  For your information, here
  5614. is a list of features that have been enhanced from Bourne.
  5615. Improvements have been made as a command language, including
  5616. command-line editing, a command history mechanism, command-name
  5617. aliasing, job control, new capabilities for cd, and tilde
  5618. expansion.  
  5619.  
  5620. Improvements as a Programming Language include a more general I/O
  5621. mechanism, Menu selection primitive, Built-in integer arithmetic,
  5622. Substring operators, Array variables and attributes, More-general
  5623. function facility, Co-process facility, Easier to debug, Better
  5624. performance, and Better security.
  5625.  
  5626. The KornShell is a high level programming language and a command
  5627. line interpreter.
  5628.  
  5629. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5630. ”  Command Format: ksh [acefhikmnorstuvx] [ -o option]...[args] ”
  5631. ”                                                               ”
  5632. ”      See the appendix for a complete list of options          ”
  5633. ”                                                               ”
  5634. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5635.  
  5636.  
  5637. 9.1  KornShell Variables
  5638.  
  5639.  
  5640. The KornShell has variables that are initialized for you on login
  5641. such as:
  5642.  
  5643. PATH      Determine which directories are searched, sequentially
  5644.           for shell commands.
  5645.  
  5646. CDPATH    The directories that are searched for arguments to the
  5647.           "cd" command.
  5648.  
  5649. SHELL     The current interactive shell.
  5650.  
  5651. PWD       The present working directory.
  5652.  
  5653. IFS       Valid inter-field separators used to separate commands
  5654.           from arguments, arguments from each other and commands
  5655.           from each other.
  5656.  
  5657. EDITOR    Command line edit mode.
  5658.  
  5659. FCEDIT    Editor entered when using fc
  5660.  
  5661. TERM      Defines terminal capabilities
  5662.  
  5663. PS1       Primary shell prompt
  5664.  
  5665. PS2       Secondary shell prompt
  5666.  
  5667. PS3       Select command prompt
  5668.  
  5669. HOME      Home directory
  5670.  
  5671. ENV       File(s) to execute when entering this shell
  5672.  
  5673. LOGNAME   Login name of the user
  5674.  
  5675.  
  5676. The command line argument variables are also available:
  5677. $$, $?, $*, $#, and the positionals ($0, $1, $2...etc)
  5678. 9.2  User Defined Variables
  5679.  
  5680.  
  5681. These variables are similar to the BourneShell.  The general form
  5682. is VARIABLE=value.
  5683.  
  5684. No spaces are allowed around the =.  You can enclose them in double
  5685. quotes "=" or single quotes '=' for clarity.  No spaces are allowed
  5686. in "value".  These can also be enclosed in double or single quotes.
  5687. "value" can be a string or an expression.  The value of a variable
  5688. can be accessed by preceding the name of the variable with a dollar
  5689. sign ($).
  5690.  
  5691. Examples:
  5692. .................................................................
  5693. . $MyString'='"This is a string"                                .
  5694. . $MyStatic=47                                                  .
  5695. . $readonly Mystatic                                            .
  5696. .................................................................
  5697.  
  5698. The readonly command makes MyStatic read only (can't change the
  5699. contents).
  5700.  
  5701. Example:
  5702. .................................................................
  5703. . $typeset -i BIGINT=1492                                       .
  5704. .................................................................
  5705.  
  5706.  
  5707. This will make the variable integer for faster arithmetics:
  5708.  
  5709. .................................................................
  5710. . $typeset -i8 OCTINT=9                                         .
  5711. .................................................................
  5712.  
  5713.  
  5714. The output of OCTINT will be an octal integer; the assignment is
  5715. decimal.
  5716.  
  5717. Sample Session:
  5718.  
  5719. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5720. ‡ $echo $OCTINT                                                 ‡
  5721. ‡ 8#11                                                          ‡
  5722. ‡ $                                                             ‡
  5723. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5724. 9.3  Values of Variables Between Child and Parent Processes
  5725.  
  5726.  
  5727. Values in one shell are local only to that shell.  If a child
  5728. process or a subshell needs to have access to a value established
  5729. in its parent, the value must be exported from the parent.
  5730.  
  5731.      $typeset -i8 -x OCTINT=19
  5732.  
  5733.  
  5734. The -x option exports the variable OCTINT; subshells can read it,
  5735. but can't change the value in the parent.
  5736.  
  5737.      $MyString='Hi there'
  5738.  
  5739.  
  5740. At this point, the variable MyString is local to the current
  5741. process.  It is not available to a child process.
  5742.  
  5743.      $export MyString
  5744.  
  5745.  
  5746. Now the variable MyString is available to subshells.
  5747.  
  5748. To allow a subshell to change the content of an exported variable
  5749. and have that change be know to the parent, execute the child with
  5750. ". program_name"
  5751.  
  5752. Sample Session:
  5753.  
  5754. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5755. ‡ $cat my.vars                                                  ‡
  5756. ‡ echo Variable coming into script: $PARENT                     ‡
  5757. ‡ PARENT='child value'                                          ‡
  5758. ‡ echo Variable coming out of the script: $PARENT               ‡
  5759. ‡ $PARENT='parent value'                                        ‡
  5760. ‡ $echo $PARENT                                                 ‡
  5761. ‡ parent value                                                  ‡
  5762. ‡ $my.vars                                                      ‡
  5763. ‡ Variable coming into script:                                  ‡
  5764. ‡ Variable coming out of the script: child value                ‡
  5765. ‡ $echo $PARENT                                                 ‡
  5766. ‡ parent value                                                  ‡
  5767. ‡ $                                                             ‡
  5768. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5769.  
  5770.  
  5771. Sample session:
  5772.           
  5773. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5774. ‡ $PARENT='parent value'                                        ‡
  5775. ‡ $echo $PARENT                                                 ‡
  5776. ‡ parent value                                                  ‡
  5777. ‡ $. my.vars                                                    ‡
  5778. ‡ Variable coming into the script: parent value                 ‡
  5779. ‡ Variable coming out of the script: child value                ‡
  5780. ‡ $echo $PARENT                                                 ‡
  5781. ‡ child value                                                   ‡
  5782. ‡ $                                                             ‡
  5783. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5784.  
  5785. 9.4  ksh: Aliases
  5786.  
  5787. The first word of each command can be replaced by the text of an
  5788. alias if an alias for this word has been defined.  The first
  5789. character of an alias name can be any printable character, but the
  5790. remaining characters must be the same as any valid identifier.
  5791. Aliases can be created, listed, and exported with the alias
  5792. command.  They can be removed with the unalias command.
  5793.  
  5794. Aliasing is performed when scripts are read but not while they are
  5795. executed.  Therefore, for an alias to take effect the alias command
  5796. has to be executed before the command which references the alias
  5797. is read.
  5798.  
  5799. The format for the alias command is as shown below.
  5800.  
  5801. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5802. ”  Command Format:  alias [-tx] [name=value]                    ”
  5803. ”                                                               ”
  5804. ”  -t = to set and list tracked aliases                         ”
  5805. ”  -x = to set or display exported aliases                      ”
  5806. ”                                                               ”
  5807. ”  name = if specified, it must be a valid alias name           ”
  5808. ”                                                               ”
  5809. ”  value = value to equate with name                            ”
  5810. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  5811.  
  5812. Example:
  5813. .................................................................
  5814. . $alias                                                        .
  5815. .................................................................
  5816.  
  5817. The command alone will display all aliases.
  5818.  
  5819. Sample Session:
  5820.  
  5821. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5822. ‡ $alias                                                        ‡
  5823. ‡ cd=c                                                          ‡
  5824. ‡ echo=print -                                                  ‡
  5825. ‡ false=let 0                                                   ‡
  5826. ‡ functions=typeset -f                                          ‡
  5827. ‡ hash=alias -t                                                 ‡
  5828. ‡ history=fc -l                                                 ‡
  5829. ‡ integer=typeset -i                                            ‡
  5830. ‡ monitor=/usr/lbin/top                                         ‡
  5831. ‡ nohup=nohup                                                   ‡
  5832. ‡ pwd=print - $PWD                                              ‡
  5833. ‡ r=fc -e -                                                     ‡
  5834. ‡ true=:                                                        ‡
  5835. ‡ type=whence -v                                                ‡
  5836. ‡ $                                                             ‡
  5837. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  5838. Suppose, instead of typing in the ls -la command to get a full,
  5839. long listing of the contents of the current directory, we want to
  5840. shorten the command to list.  Enter the following command to set
  5841. the alias.
  5842.  
  5843. Example:
  5844. .................................................................
  5845. . $alias list='ls -la'                                          .
  5846. .................................................................
  5847.  
  5848. Now when you type in the command list, the alias will substitute
  5849. the command ls -la for list; and the long listing will be
  5850. displayed.
  5851.  
  5852.  
  5853. Sample Session:
  5854.  
  5855. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  5856. ‡ $list                                                         ‡
  5857. ‡ total 54   0                                                  ‡
  5858. ‡ drwx------  4 teacher  class   2590  May 1 09:39  .           ‡
  5859. ‡ drwxr-xr-x 63 teacher  class   1536  Sep 9 13:11  ..          ‡
  5860. ‡ -rw-r--r--  1 teacher  class     64  Jul 4 10:33  .assistrc   ‡
  5861. .                                                               .
  5862. .                                                               .
  5863.  
  5864. 9.5  ksh: Command Line Editing
  5865.  
  5866. There are two forms of command-line editing in the KornShell. Both
  5867. use the command history in the file indicated by the KornShell
  5868. variable HISTFILE (default is HISTFILE=$HOME/.history).
  5869.  
  5870. Editing commands in the history file is accomplished with fc (fix
  5871. command).  To get a list of commands in the .history file, you
  5872. enter the fc -l command at the dollar ($).
  5873.  
  5874. By default, the alias history may also be used.
  5875.  
  5876. Editing a command in the .history file with the fc command is
  5877. controlled by the KornShell variable FCEDIT.  FCEDIT determines
  5878. the editor that the fc command will use.
  5879.  
  5880. Example:
  5881. .................................................................
  5882. .  $FCEDIT=/usr/bin/vi                                          .
  5883. .  $fc                                                          .
  5884. .................................................................
  5885.  
  5886. The KornShell variable causes the fc command to use the vi editor. 
  5887. The fc command, by itself, will take you into the vi editor with
  5888. the most recent command.  In this example, upon exiting the vi
  5889. editor, the edited command will be executed.
  5890.  
  5891. Example:
  5892. .................................................................
  5893. . $ct .profile                                                  .
  5894. . .profile: No such file or directory                           .
  5895. . $fc -e - ct=cat c                                             .
  5896. .................................................................
  5897.  
  5898. The first line is a deliberate mistake; notice the error message.
  5899. The fc command executes the most recent command that starts with
  5900. a "c" and changes the first occurrence of "ct" to "cat"; it doesn't
  5901. enter the editor.
  5902.  
  5903. Example:
  5904. .................................................................
  5905. . $ls /                                                         .
  5906. . $fc -e - ls=cd                                                .
  5907. .................................................................
  5908.  
  5909. The first command will list the contents of the root directory.
  5910. The fc command changes that command from "ls" to "cd"; the "-"
  5911. indicates that the line is to be edited instead of taken into the
  5912. editor before execution.
  5913. 9.6  ksh: Interactive Command Line Editing
  5914.  
  5915.  
  5916. In this method of command-line editing, the EDITOR KornShell
  5917. variable controls the editing.
  5918.  
  5919. Example:
  5920. .................................................................
  5921. . $EDITOR=/usr/bin/vi                                           .
  5922. .................................................................
  5923.  
  5924.  
  5925. This command will put the KornShell in the vi editing mode.
  5926.  
  5927. To enter the edit history press Esc.
  5928.  
  5929. NOTE:     This example is for the vi edit mode only; emacs or 
  5930.           gmacs edit modes use different key stokes.
  5931.  
  5932. To move though the .history file use following keys:
  5933.  
  5934.      <k>                      Select the previous command
  5935.  
  5936.      <j>                      Select the next command
  5937.  
  5938.      <h>                      Next letter to the left
  5939.  
  5940.      <l>                      Next letter to the right
  5941.  
  5942.  
  5943. When the command line that you desire to change is displayed on
  5944. the screen, you can use the following commands to make changes:
  5945.  
  5946.  
  5947.      <i> insert chars Esc          Insert characters before the
  5948.                                    cursor
  5949.  
  5950.      <A> append chars Esc          Append characters at the end of
  5951.                                    the line
  5952.  
  5953.      <r> replacement char Esc      Change single character
  5954.  
  5955.      <cw> replacement word Esc     Change single word
  5956.  
  5957.      <x>                           Delete single character
  5958.  
  5959.      NOTE:     A number can precede the command as a count, for
  5960.                example, "3x" deletes 3 characters.
  5961.  
  5962.      <dw>                          Delete single word
  5963.  
  5964.      NOTE:     A number can precede the command as a count, for
  5965.                example, "2dw" deletes 2 words.
  5966.  
  5967.      (Ret)                         Execute the altered command
  5968.  
  5969.  
  5970. When the (Ret) key is pressed, the edited command line will be
  5971. executed.  History is not changed, but the new command is entered
  5972. into the .history file at the end.
  5973.  
  5974. These are not the only commands available with the interactive
  5975. command line editing.  You will find that the arrow keys will not
  5976. work while editing the command line.  Most of the editor features
  5977. will be available for you to use, depending upon which editor was
  5978. selected by the EDITOR shell variable.
  5979. 9.7  ksh: Functions
  5980.  
  5981.  
  5982. Functions are similar to aliases, they run in the current KornShell
  5983. process and define a set of actions.  Positional parameters can be
  5984. referenced; other previously defined functions can be referenced;
  5985. nested function definitions are allowed with full visibility to all
  5986. definitions.
  5987.  
  5988. The function keyword is used to define KornShell functions.  The
  5989. functions are read in and stored internally.  Any alias names are
  5990. resolved when the function is read.  Functions are executed like
  5991. commands with arguments passed as positional parameters.
  5992.  
  5993. Functions execute in the same process as the caller and share all
  5994. files, traps, and present working directory with the caller.
  5995.  
  5996. The format for functions is:
  5997.  
  5998. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  5999. ”  Command Format:                                              ”
  6000. ”                                                               ”
  6001. ”  function  identifier                                         ”
  6002. ”  {                                                            ”
  6003. ”        compound list                                          ”
  6004. ”  }                                                            ”
  6005. ”                                                               ”
  6006. ”  identifier - name by which the function is called            ”
  6007. ”                                                               ”
  6008. ”  compound list - The body of the function.                    ”
  6009. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  6010.  
  6011. The left bracket { and the right bracket } are considered to be
  6012. reserved words.  The body of the function must exist between the
  6013. two brackets.
  6014.  
  6015. Sample Session:
  6016.  
  6017. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  6018. ‡ $function k                                                   ‡
  6019. ‡ {                                                             ‡
  6020. ‡ cd /; ls -C;                                                  ‡
  6021. ‡ }                                                             ‡
  6022. ‡ $                                                             ‡
  6023. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  6024.  
  6025. To execute the function, simply type the name of the function on
  6026. the command line.
  6027.  
  6028. Sample Session:
  6029.  
  6030. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  6031. ‡ $k                                                            ‡
  6032. ‡ bck          lib       tmp       user12         user5         ‡
  6033. ‡ bin          lost      tmp.ja    user13         user6         ‡
  6034. ‡ bsd          nbox      unix      user14         user7         ‡
  6035. .                                                               .
  6036. .                                                               .
  6037. .                                                               .
  6038. 9.8  ksh: The Select Construct
  6039.  
  6040.  
  6041. The "select" construct is unique to the KornShell.  It allows the
  6042. user to determine the action based on input from either the command
  6043. line (without an in list) or from an automatically prompted input. 
  6044. PS3 controls the "select" prompt.
  6045.  
  6046. The command format is as follows:
  6047.                                                                  
  6048. ²˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝»
  6049. ”  Command Format:  select identifier [in list]                 ”
  6050. ”                   do                                          ”
  6051. ”                        commands                               ”
  6052. ”                   done                                        ”
  6053. ”                                                               ”
  6054. ¨˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝˝…
  6055.  
  6056. In the select command:
  6057.  
  6058. ksh will display the items in one or more columns on standard
  6059. error, each preceded by a number.  The PS3 prompt follows.  The
  6060. number of columns is determined by the values of COLUMNS and LINES.
  6061.  
  6062. ksh will then read a selection line from standard input.  If the
  6063. line is the number of one of the displayed items, ksh sets the
  6064. value of "identifier" to the item corresponding to this number. If
  6065. the line is empty, ksh again displays the list of items; and the
  6066. prompt is redisplayed.  The "commands" are not executed.
  6067.  
  6068. ksh saves the contents of the selection line read from standard
  6069. input in the KornShell variable REPLY.
  6070.  
  6071. ksh runs "commands" for each selection until ksh encounters a
  6072. break, return, or exit command in the "commands" list.
  6073. Sample Session:
  6074.  
  6075. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  6076. ‡ $cat select.ksh                                               ‡
  6077. ‡ stty erase                                                    ‡
  6078. ‡ select myselection in fred wilma pebbles barney betty         ‡
  6079. ‡ do                                                            ‡
  6080. ‡ case $myselection in                                          ‡
  6081. ‡    fred)                                                      ‡
  6082. ‡         echo Fred was the selection                           ‡
  6083. ‡         ;;                                                    ‡
  6084. ‡    wilma)                                                     ‡
  6085. ‡         echo Wilma was the selection                          ‡
  6086. ‡         ;;                                                    ‡
  6087. ‡    pebbles)                                                   ‡
  6088. ‡         echo Pebbles was the selection                        ‡
  6089. ‡         ;;                                                    ‡
  6090. ‡    barney)                                                    ‡
  6091. ‡         echo Barney was the selection                         ‡
  6092. ‡         ;;                                                    ‡
  6093. ‡    betty)                                                     ‡
  6094. ‡         echo Betty was the selection                          ‡
  6095. ‡         ;;                                                    ‡
  6096. ‡ esac                                                          ‡
  6097. ‡ done                                                          ‡
  6098. ‡ $chmod 755 select.ksh                                         ‡
  6099. ‡ $select.ksh                                                   ‡
  6100. ‡ 1) fred                                                       ‡
  6101. ‡ 2) wilma                                                      ‡
  6102. ‡ 3) pebbles                                                    ‡
  6103. ‡ 4) barney                                                     ‡
  6104. ‡ 5) betty                                                      ‡
  6105. ‡ #? 3                                                          ‡
  6106. ‡ Pebbles was the selection                                     ‡
  6107. ‡ #? 5                                                          ‡
  6108. ‡ Betty was the selection                                       ‡
  6109. ‡ #? 6                                                          ‡
  6110. ‡ #? 4                                                          ‡
  6111. ‡ Barney was the selection                                      ‡
  6112. ‡ # Ctrl-C                                                      ‡
  6113. ‡ $                                                             ‡
  6114. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  6115. 9.9  ksh: Tracing and Conditional Execution
  6116.  
  6117.  
  6118. A KornShell script that is not executable can be run implicitly
  6119. with the ksh command.  Tracing can be accomplished using the
  6120. -v or the -x option.
  6121.  
  6122. Sample Session:
  6123.  
  6124. 嘘˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜¿
  6125. ‡ $ls -l select.ksh                                             ‡
  6126. ‡ -rw-r--r-- 1 teacher class 390 Oct 16 09:21 select.ksh        ‡
  6127. ‡ $ksh -x select.ksh                                            ‡
  6128. ‡ + stty erase                                                  ‡
  6129. ‡ 1) fred                                                       ‡
  6130. ‡ 2) wilma                                                      ‡
  6131. ‡ 3) pebbles                                                    ‡
  6132. ‡ 4) barney                                                     ‡
  6133. ‡ 5) betty                                                      ‡
  6134. ‡ #? 3                                                          ‡
  6135. ‡ + print - Pebbles was the selection                           ‡
  6136. ‡ Pebbles was the selection                                     ‡
  6137. ‡ #? 5                                                          ‡
  6138. ‡ + print - Betty was the selection                             ‡
  6139. ‡ Betty was the selection                                       ‡
  6140. ‡ #? 6                                                          ‡
  6141. ‡ #? 4                                                          ‡
  6142. ‡ + print - Barney was the selection                            ‡
  6143. ‡ Barney was the selection                                      ‡
  6144. ‡ #? Ctrl-C                                                     ‡
  6145. ‡ $                                                             ‡
  6146. ¹˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜ä
  6147.  
  6148. The -n option will trace execution of the script without execution.
  6149. Workshop 9
  6150.  
  6151. This workshop will reinforce your understanding of the ideas
  6152. presented in Chapter 10. Login to the Multimax using the username
  6153. and password given to you by the instructor.  Each student is to
  6154. complete the entire workshop.
  6155.  
  6156. DESK EXERCISES
  6157.  
  6158.  
  6159.      1.   What command will invoke the KornShell?
  6160.  
  6161.  
  6162.  
  6163.  
  6164.  
  6165.  
  6166.  
  6167.      2.   What option will trace execution of a KornShell script?
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.                      Continue on the next page
  6175.      3.   What do the following shell variables indicate:
  6176.  
  6177.  
  6178.           PATH
  6179.  
  6180.  
  6181.           CDPATH
  6182.  
  6183.  
  6184.           SHELL
  6185.  
  6186.  
  6187.           PWD
  6188.  
  6189.  
  6190.           IFS
  6191.  
  6192.  
  6193.           EDITOR
  6194.  
  6195.  
  6196.           FCEDIT
  6197.  
  6198.  
  6199.           TERM
  6200.  
  6201.  
  6202.           PS1
  6203.  
  6204.  
  6205.           PS2
  6206.  
  6207.  
  6208.           PS3  
  6209.  
  6210.  
  6211.           HOME
  6212.  
  6213.  
  6214.           ENV
  6215.  
  6216.  
  6217.           LOGNAME
  6218.  
  6219.  
  6220.  
  6221.                      Continue on the next page
  6222.           4.   What is an alias?
  6223.  
  6224.  
  6225.  
  6226.  
  6227.  
  6228.  
  6229. COMPUTER EXERCISES (30 minutes)
  6230.  
  6231.  
  6232.      5.   Define a function k that will:
  6233.  
  6234.           Display the present working directory, display a message
  6235.           that a listing will follow, sleep for three seconds, and
  6236.           then list the contents.
  6237.  
  6238.  
  6239.  
  6240.  
  6241.  
  6242.  
  6243.  
  6244.      6.   Set up an alias to do the ls -C function. Use a name of
  6245.           your own choice.
  6246.  
  6247.  
  6248.  
  6249.  
  6250.  
  6251.  
  6252.  
  6253.      7.   Write a KornShell script using the  select command to
  6254.           display the following choices:
  6255.  
  6256.           Apples
  6257.           Bananas
  6258.           Pears
  6259.           Jack Daniels
  6260.  
  6261.           After a choice has been made print the following:
  6262.  
  6263.           "Thanks, your choice was" (display the choice)
  6264.  
  6265.  
  6266.  
  6267.      8.   Logout
  6268.  
  6269.  
  6270.  
  6271.  
  6272.  
  6273.                      Continue on the next page
  6274.                   Complete the Summary Workshop 
  6275.  
  6276.                                 and
  6277.  
  6278.                          Course Evaluation
  6279.                                NOTES
  6280. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  6281. APPENDIX A - sh
  6282.  
  6283.  
  6284. NAME
  6285.      sh, rsh - shell, the standard/restricted command programming
  6286.      language
  6287.  
  6288. SYNOPSIS
  6289.      sh [ -acefhiknrstuvx ] [ args ]
  6290.      rsh [ -acefhiknrstuvx ] [ args ]
  6291.  
  6292. DESCRIPTION                                                                   
  6293.      sh is a command programming language that executes commands
  6294.      read from a terminal or a file.  rsh is a restricted version
  6295.      of the standard command interpreter sh; it is used to set up
  6296.      login names and execution environments whose capabilities
  6297.      are more controlled than those of the standard shell.  See
  6298.      Invocation below for the meaning of arguments to the shell.
  6299.                                                                 
  6300.                                                                 
  6301.    Definitions                                                          
  6302.      A blank is a tab or a space.  A name is a sequence of
  6303.      letters, digits, or underscores beginning with a letter or
  6304.      underscore.  A parameter is a name, a digit, or any of the         
  6305.      characters *, @, #, ?, -, $, and !.                                
  6306.                                                                         
  6307.    Commands                                                             
  6308.      A simple-command is a sequence of non-blank words separated        
  6309.      by blanks.  The first word specifies the name of the command       
  6310.      to be executed.  Except as specified below, the remaining          
  6311.      words are passed as arguments to the invoked command.  The         
  6312.      command name is passed as argument 0 (see exec(2)).  The           
  6313.      value of a simple-command is its exit status if it                 
  6314.      terminates normally, or (octal) 200+status if it terminates        
  6315.      abnormally (see signal(2) for a list of status values).            
  6316.                                                                         
  6317.      A pipeline is a sequence of one or more commands separated         
  6318.      by |.  The standard output of each command but the last is         
  6319.      connected by a pipe(2) to the standard input of the next           
  6320.      command.  Each command is run as a separate process; the           
  6321.      shell waits for the last command to terminate.  The exit           
  6322.      status of a pipeline is the exit status of the last command.       
  6323.                                                                         
  6324.      A list is a sequence of one or more pipelines separated by         
  6325.      ;, &, &&, or ||, and optionally terminated by ; or &.  Of          
  6326.      these four symbols, ; and & have equal precedence, which is        
  6327.      lower than that of && and ||.  The symbols && and || also          
  6328.      have equal precedence.  A semicolon (;) causes sequential         
  6329.      execution of the preceding pipeline; an ampersand (&) causes      
  6330.      asynchronous execution of the preceding pipeline (i.e., the       
  6331.      shell does not wait for that pipeline to finish).  The            
  6332.      symbol && (||) causes the list following it to be executed        
  6333.      only if the preceding pipeline returns a zero (non-zero)          
  6334.      exit status.  An arbitrary number of new-lines may appear in      
  6335.      a list, instead of semicolons, to delimit commands.               
  6336.                                                                        
  6337.      A command is either a simple-command or one of the                
  6338.      following.  Unless otherwise stated, the value returned by a
  6339.      command is that of the last simple-command executed in the        
  6340.      command.                                                          
  6341.                                                                        
  6342.      for name [ in word ... ] do list done                             
  6343.           Each time a for command is executed, name is set to the      
  6344.           next word taken from the in word list.  If in word ...       
  6345.           is omitted, then the for command executes the do list        
  6346.           once for each positional parameter that is set (see          
  6347.           Parameter Substitution below).  Execution ends when          
  6348.           there are no more words in the list.                         
  6349.     case word in [ pattern [ | pattern ] ... ) list ;; ] ... esac      
  6350.           A case command executes the list associated with the         
  6351.           first pattern that matches word.  The form of the            
  6352.           patterns is the same as that used for file-name              
  6353.           generation (see File Name Generation) except that a
  6354.           slash, a leading dot, or a dot immediately following a
  6355.           slash need not be matched explicitly.                        
  6356.    if list then list [ elif list then list ] ... [ else list ] fi      
  6357.           The list following if is executed and, if it returns a
  6358.           zero exit status, the list following the first then is
  6359.           executed.  Otherwise, the list following elif is      
  6360.           executed and, if its value is zero, the list following
  6361.           the next then is executed.  Failing that, the else lis
  6362.           is executed.  If no else list or then list is executed
  6363.           then the if command returns a zero exit status.       
  6364.      while list do list done                                    
  6365.           A while command repeatedly executes the while list and
  6366.           if the exit status of the last command in the list is 
  6367.           zero, executes the do list; otherwise the loop        
  6368.           terminates.  If no commands in the do list are        
  6369.           executed, then the while command returns a zero exit  
  6370.           status; until may be used in place of while to negate 
  6371.           the loop termination test.                            
  6372.      (list)                                                     
  6373.           Execute list in a sub-shell.                         
  6374.      { list; }                                                 
  6375.           list is executed in the current (that is, parent)    
  6376.           shell.                                               
  6377.      name () { list; }                                         
  6378.           Define a function which is referenced by name.  The  
  6379.           body of the function is the list of commands between {
  6380.           and }.  Execution of functions is described below (see        
  6381.           Execution).                                                   
  6382.                                                                         
  6383.      The following words are only recognized as the first word of       
  6384.      a command and when not quoted:                                     
  6385.                                                                         
  6386.           if  then  else  elif  fi  case  esac  for  while  until       
  6387.           do  done  {}                                                  
  6388.                                                                         
  6389.    Comments                                                             
  6390.      A word beginning with # causes that word and all the               
  6391.      following characters up to a new-line to be ignored.               
  6392.                                                                         
  6393.    Command Substitution                                                 
  6394.      The shell reads commands from the string between two grave         
  6395.      accents (``) and the standard output from these commands may       
  6396.      be used as all or part of a word.  Trailing new-lines from         
  6397.      the standard output are removed.                                   
  6398.                                                                         
  6399.      No interpretation is done on the string before the string is       
  6400.      read, except to remove backslashes (\) used to escape other        
  6401.      characters.  Backslashes may be used to escape a grave             
  6402.      accent (`) or another backslash (\) and are removed before         
  6403.      the command string is read.  Escaping grave accents allows         
  6404.      nested command substitution.  If the command substitution          
  6405.      lies within a pair of double quotes (" ...` ...` ... "), a
  6406.      backslash used to escape a double quote (\") will be                
  6407.      removed; otherwise, it will be left intact.                        
  6408.                                                                         
  6409.      If a backslash is used to escape a new-line character              
  6410.      (\new-line), both the backslash and the new-line are removed       
  6411.      (see the later section on Quoting).  In addition,                  
  6412.      backslashes used to escape dollar signs (\$) are removed.          
  6413.      Since no interpretation is done on the command string before       
  6414.      it is read, inserting a backslash to escape a dollar sign          
  6415.      has no effect.  Backslashes that precede characters other          
  6416.      than \, `, ", new-line, and $ are left intact when the             
  6417.      command string is read.                                            
  6418.                                                                         
  6419.    Parameter Substitution                                               
  6420.      The character $ is used to introduce substitutable                 
  6421.      parameters.  There are two types of parameters, positional         
  6422.      and keyword.  If parameter is a digit, it is a positional          
  6423.      parameter.  Positional parameters may be assigned values by        
  6424.      set.  Keyword parameters (also known as variables) may be          
  6425.      assigned values by writing:                                        
  6426.                                                                         
  6427.           name=value [ name=value ] ...                                 
  6428.                                                                         
  6429.      Pattern-matching is not performed on value.  There cannot be       
  6430.      a function and a variable with the same name.                      
  6431.                                                                         
  6432.      ${parameter}                                                       
  6433.           The value, if any, of the parameter is substituted.           
  6434.           The braces are required only when parameter is followed       
  6435.           by a letter, digit, or underscore that is not to be           
  6436.           interpreted as part of its name.  If parameter is * or        
  6437.           @, all the positional parameters, starting with $1, are       
  6438.           substituted (separated by spaces).  Parameter $0 is set       
  6439.           from argument zero when the shell is invoked.                 
  6440.      ${parameter:-word}                                                 
  6441.           If parameter is set and is non-null, substitute its           
  6442.           value; otherwise substitute word.                             
  6443.      ${parameter:=word}                                                 
  6444.           If parameter is not set or is null set it to word; the        
  6445.           value of the parameter is substituted.  Positional            
  6446.           parameters may not be assigned to in this way.                
  6447.      ${parameter:?word}                                                 
  6448.           If parameter is set and is non-null, substitute its           
  6449.           value; otherwise, print word and exit from the shell.         
  6450.           If word is omitted, the message "parameter null or not        
  6451.           set" is printed.                                              
  6452.      ${parameter:+word}                                                 
  6453.           If parameter is set and is non-null, substitute word;         
  6454.           otherwise substitute nothing.                                
  6455.                                                                        
  6456.      In the above, word is not evaluated unless it is to be used       
  6457.      as the substituted string, so that, in the following              
  6458.      example, pwd is executed only if d is not set or is null:        
  6459.                                                                       
  6460.           echo ${d:-`pwd`}                                            
  6461.                                                                       
  6462.      If the colon (:) is omitted from the above expressions, the      
  6463.      shell only checks whether parameter is set or not.               
  6464.                                                                       
  6465.      The following parameters are automatically set by the shell:     
  6466.           #    The number of positional parameters in decimal.        
  6467.           -    Flags supplied to the shell on invocation or by         
  6468.                the set command.                                        
  6469.           ?    The decimal value returned by the last                
  6470.                synchronously executed command.                       
  6471.           $    The process number of this shell.                     
  6472.           !    The process number of the last background command     
  6473.                invoked.                                               
  6474.                                                                       
  6475.      The following parameters are used by the shell:                  
  6476.           HOME  The default argument (home directory) for the cd      
  6477.                 command.                                              
  6478.           PATH  The search path for commands (see Execution           
  6479.                    below).  The user may not change PATH if                   
  6480.          executing under rsh.                                     
  6481.           CDPATH                                                  
  6482.                 The search path for the cd command.               
  6483.           MAIL  If this parameter is set to the name of a mail    
  6484.                 file and the MAILPATH parameter is not set, the   
  6485.                 shell informs the user of the arrival of mail in  
  6486.                 the specified file.                               
  6487.           MAILCHECK                                               
  6488.                 This parameter specifies how often (in seconds)       
  6489.                 the shell will check for the arrival of mail in       
  6490.                 the files specified by the MAILPATH or MAIL           
  6491.                 parameters.  The default value is 600 seconds (10     
  6492.                 minutes).  If set to 0, the shell will check          
  6493.                 before each prompt.                                   
  6494.           MAILPATH                                                   
  6495.                 A colon (:) separated list of file names.  If         
  6496.                 this parameter is set, the shell informs the user    
  6497.                 of the arrival of mail in any of the specified       
  6498.                 files. Each file name can be followed by % and a
  6499.                 message that will be printed when the                
  6500.                 modification time changes.  The default message      
  6501.                 is you have mail.                                      
  6502.           PS1   Primary prompt string, by default "$ ".                
  6503.           PS2   Secondary prompt string, by default "> ".              
  6504.           IFS   Internal field separators, normally space, tab,        
  6505.                 and new-line.                                          
  6506.           SHACCT                                               
  6507.                 If this parameter is set to the name of a file 
  6508.                 writable by the user, the shell will write an          
  6509.                 accounting record in the file for each shell           
  6510.                 procedure executed.  Accounting routines such as       
  6511.                 acctcom(1) and acctcms(1M) can be used to analyze      
  6512.                 the data collected.                                   
  6513.           SHELL When the shell is invoked, it scans the                
  6514.                 environment (see Environment below) for this           
  6515.                 name.  If it is found and 'rsh' is the file name       
  6516.                 part of its value, the shell becomes a restricted      
  6517.                 shell.                                                 
  6518.                                                                        
  6519.      The shell gives default values to PATH, PS1, PS2, MAILCHECK       
  6520.      and IFS.  HOME and MAIL are set by login(1).                      
  6521.                                                                        
  6522.    Blank Interpretation                                                
  6523.      After parameter and command substitution, the results of         
  6524.      substitution are scanned for internal field separator            
  6525.      characters (those found in IFS) and split into distinct          
  6526.      arguments where such characters are found.  Explicit null        
  6527.      arguments ("" or '') are retained.  Implicit null arguments      
  6528.      (those resulting from parameters that have no values) are        
  6529.      removed.                                                        
  6530.                                                                      
  6531.    Input/Output                                                       
  6532.      A command's input and output may be redirected using a
  6533.      special notation interpreted by the shell.  The following     
  6534.      may appear anywhere in a simple-command or may precede or     
  6535.      follow a command and are not passed on to the invoked            
  6536.      command; substitution occurs before word or digit is used:       
  6537.                                                                       
  6538.      <word         Use file word as standard input (file              
  6539.                    descriptor 0).                                     
  6540.      >word         Use file word as standard output (file             
  6541.                    descriptor 1).  If the file does not exist it      
  6542.                    is created; otherwise, it is truncated to zero     
  6543.                    length.                                            
  6544.      >>word        Use file word as standard output.  If the file     
  6545.                    exists output is appended to it (by first          
  6546.                    seeking to the end-of-file); otherwise, the        
  6547.                    file is created.                                   
  6548.      <<[-]word     After parameter and command substitution are       
  6549.                    done on word, the shell input is read up to        
  6550.                    the first line that literally matches the          
  6551.                    resulting word, or to an end-of-file.  If,         
  6552.                    however, - is appended to <<:                      
  6553.                    1)  leading tabs are stripped from word before     
  6554.                        the shell input is read (but after             
  6555.                        parameter and command substitution is done     
  6556.                        on word),                                      
  6557.                    2)  leading tabs are stripped from the shell       
  6558.                        input as it is read and before each line       
  6559.                        is compared with word, and                     
  6560.                    3)  shell input is read up to the first line       
  6561.                        that literally matches the resulting word,     
  6562.                        or to an end-of-file.                          
  6563.                    If any character of word is quoted (see            
  6564.                    Quoting, later), no additional processing is       
  6565.                    done to the shell input.  If no characters of      
  6566.                    word are quoted:                                   
  6567.                    1)  parameter and command substitution occurs,     
  6568.                    2)  (escaped) \newline is ignored, and             
  6569.                    3)  \ must be used to quote the characters \,      
  6570.                        $, and `.                                       
  6571.                    The resulting document becomes the standard         
  6572.                    input.                                              
  6573.      <&digit       Use the file associated with file descriptor        
  6574.                    digit as standard input.  Similarly for the         
  6575.                    standard output using >&digit.                     
  6576.      <&-           The standard input is closed.  Similarly for       
  6577.                    the standard output using >&--.                    
  6578.                                                                       
  6579.      If any of the above is preceded by a digit, the file             
  6580.      descriptor which will be associated with the file is that        
  6581.      specified by the digit (instead of the default 0 or 1).  For     
  6582.      example:                                                         
  6583.                                                                       
  6584.           ... 2>&1                                                    
  6585.                                                                       
  6586.      associates file descriptor 2 with the file currently             
  6587.      associated with file descriptor 1.                               
  6588.                                                                       
  6589.      The order in which redirections are specified is                 
  6590.      significant.  The shell evaluates redirections left-to-          
  6591.      right.  For example:                                             
  6592.                                                                      
  6593.           ... 1>xxx  2>&1                                            
  6594.                                                                       
  6595.      first associates file descriptor 1 with file xxx.  It            
  6596.      associates file descriptor 2 with the file associated with       
  6597.      file descriptor 1 (i.e. xxx).  It directs both standard          
  6598.      output and standard error output (stdout, stderr) to xxx.        
  6599.      If the order of redirections were reversed, file descriptor      
  6600.      2 would be associated with the terminal (assuming file           
  6601.      descriptor 1 had been) and file descriptor 1 would be            
  6602.      associated with file xxx.                                        
  6603.                                                                       
  6604.      Using the terminology introduced on the first page, under       
  6605.      Commands, if a command is composed of several simple            
  6606.      commands, redirection will be evaluated for the entire           
  6607.      command before it is evaluated for each simple command.          
  6608.      That is, the shell evaluates redirection for the entire          
  6609.      list, then each pipeline within the list, the each command       
  6610.      within each pipeline, then each list within each command.        
  6611.                                                                       
  6612.      If a command is followed by & the default standard input for    
  6613.      the command is the empty file /dev/null.  Otherwise, the        
  6614.      environment for the execution of a command contains the file    
  6615.      descriptors of the invoking shell as modified by                
  6616.      input/output specifications.                                    
  6617.                                                                    
  6618.      Redirection of output is not allowed in the restricted        
  6619.      shell.                                                           
  6620.                                                                       
  6621.    File Name Generation                                                
  6622.      Before a command is executed, each command word is scanned        
  6623.      for the characters *, ?, and [.  If one of these characters      
  6624.      appears, the word is regarded as a pattern.  The word is         
  6625.      replaced with alphabetically sorted file names that match         
  6626.      the pattern.  If no file name is found that matches the          
  6627.      pattern, the word is left unchanged.  The character . at the     
  6628.      start of a file name or immediately following a /, as well       
  6629.      as the character / itself, must be matched explicitly.           
  6630.                                                                     
  6631.           *       Matches any string, including the null string.    
  6632.           ?       Matches any single character.                     
  6633.           [...]   Matches any one of the enclosed characters.  A
  6634.                   pair of characters separated by - matches any     
  6635.                   character lexically between the pair,             
  6636.                   inclusive.  If the first character following      
  6637.                   the opening "[" is a "!" any character not        
  6638.                   enclosed is matched.                              
  6639.                                                                     
  6640.    Quoting                                                          
  6641.      The following characters have a special meaning to the shell  
  6642.      and cause termination of a word unless quoted:                
  6643.                                                                    
  6644.           ;  &  (  )  |  ^  <  >  new-line  space  tab
  6645.                                                                    
  6646.      A character may be quoted (i.e., made to stand for itself)    
  6647.      by preceding it with a backslash (\) or inserting it between 
  6648.      a pair of quote marks ('' or "").  During processing, the    
  6649.      shell may quote certain characters to prevent them from      
  6650.      taking on a special meaning. Backslashes used to quote a
  6651.      single character are removed from the word before the       
  6652.      command is executed.  The pair \newline is removed from a
  6653.      word before command and parameter substitution.             
  6654.                                                                  
  6655.      All characters enclosed between a pair of single quote marks
  6656.      (''), except a single quote, are quoted by the shell.      
  6657.      Backslash has no special meaning inside a pair of single   
  6658.      quotes.  A single quote may be quoted inside a pair of    
  6659.      double quote marks (for example, "'").                    
  6660.                                                                
  6661.      Inside a pair of double quote marks (""), parameter and   
  6662.      command substitution occurs and the shell quotes the results  
  6663.      to avoid blank interpretation and file name generation. If    
  6664.      $* is within a pair of double quotes, the positional          
  6665.      parameters are substituted and quoted, separated by quoted    
  6666.      spaces ("$1 $2 ..."); however, if $@ is within a pair of        
  6667.      double quotes, the positional parameters are substituted and    
  6668.      quoted, separated by unquoted spaces ("$1" "$2" ...).  \        
  6669.      quotes the characters \, `, ", and $.  The pair \newline is     
  6670.      removed before parameter and command substitution.  If a
  6671.      backslash precedes characters other than \, `, ", $, and        
  6672.      new-line, the backslash itself is quoted by the shell.          
  6673.                                                                      
  6674.    Prompting                                                         
  6675.      When used interactively, the shell prompts with the value of    
  6676.      PS1 before reading a command.  If at any time a new-line is      
  6677.      typed and further input is needed to complete a command, the     
  6678.      secondary prompt (i.e., the value of PS2) is issued.             
  6679.                                                                        
  6680.    Environment                                                         
  6681.      The environment (see environ(5)) is a list of name-value          
  6682.      pairs that is passed to an executed program in the same way       
  6683.      as a normal argument list.  The shell interacts with the         
  6684.      environment in several ways.  On invocation, the shell scans     
  6685.      the environment and creates a parameter for each name found,     
  6686.      giving it the corresponding value.  If the user modifies the     
  6687.      value of any of these parameters or creates new parameters,      
  6688.      none of these affects the environment unless the export          
  6689.      command is used to bind the shell's parameter to the             
  6690.      environment (see also set -a).  A parameter may be removed       
  6691.      from the environment with the unset command.  The                
  6692.      environment seen by any executed command is thus composed of     
  6693.      any unmodified name-value pairs originally inherited by the      
  6694.      shell, minus any pairs removed by unset, plus any                
  6695.      modifications or additions, all of which must be noted in         
  6696.      export commands.                                                  
  6697.                                                                        
  6698.      The environment for any simple-command may be augmented by        
  6699.      prefixing it with one or more assignments to parameters.          
  6700.      Thus:                                                             
  6701.                                                                        
  6702.           TERM=450 cmd                                                 
  6703.      and                                                               
  6704.           (export TERM; TERM=450; cmd)                                 
  6705.                                                                        
  6706.      are equivalent (as far as the execution of cmd is                 
  6707.      concerned).                                                       
  6708.                                                                        
  6709.      If the -k flag is set, all keyword arguments are placed in        
  6710.      the environment, even if they occur after the command name.       
  6711.      The following first prints a=b c and c:                          
  6712.                                                                       
  6713.           echo a=b c                                                 
  6714.           set -k                                                     
  6715.           echo a=b c                                                   
  6716.                                                                        
  6717.    Signals                                                             
  6718.      The INTERRUPT and QUIT signals for an invoked command are         
  6719.      ignored if the command is followed by &; otherwise signals       
  6720.      have the values inherited by the shell from its parent, with     
  6721.      the exception of signal 11 (SIGSEGV) (but see also the trap      
  6722.      command below).  See nohup(1) for more signal handling.          
  6723.                                                                        
  6724.    Execution                                                           
  6725.      Each time a command is executed, the above substitutions are      
  6726.      carried out.  If the command name matches one of the Special      
  6727.      Commands listed below, it is executed in the shell process.       
  6728.      If the command name does not match a Special Command, but         
  6729.      matches the name of a defined function, the function is          
  6730.      executed in the shell process (note how this differs from        
  6731.      the execution of shell procedures).  The positional               
  6732.      parameters $1, $2, ....  are set to the arguments of the          
  6733.      function.  If the command name matches neither a Special          
  6734.      Command nor the name of a defined function, a new process is      
  6735.      created and an attempt is made to execute the command via
  6736.      exec(2).                                                          
  6737.                                                                        
  6738.      The shell parameter PATH defines the search path for the          
  6739.      directory containing the command.  Alternative directory         
  6740.      names are separated by a colon (:).  The default path is         
  6741.      :/bin:/usr/bin (specifying the current directory, /bin, and       
  6742.      /usr/bin, in that order).  Note that the current directory        
  6743.      is specified by a null path name, which can appear                
  6744.      immediately after the equal sign or between the colon             
  6745.      delimiters anywhere else in the path list.  If the command        
  6746.      name contains a / the search path is not used; such commands      
  6747.      will not be executed by the restricted shell.  Otherwise,         
  6748.      each directory in the path is searched for an executable          
  6749.      file.  If the file has execute permission but is not an          
  6750.      a.out file, it is assumed to be a file containing shell          
  6751.      commands.  A sub-shell is spawned to read it.  A
  6752.      parenthesized command is also executed in a sub-shell.           
  6753.                                                                       
  6754.      The location in the search path where a command was found is     
  6755.      remembered by the shell (to help avoid unnecessary execs         
  6756.      later).  If the command was found in a relative directory,       
  6757.      its location must be re-determined whenever the current         
  6758.      directory changes.  The shell forgets all remembered            
  6759.      locations whenever the PATH variable is changed or the hash      
  6760.      -r command is executed (see below).                              
  6761.                                                                       
  6762.    Special Commands                                                   
  6763.      Input/output redirection is now permitted for these              
  6764.      commands.  File descriptor 1 is the default output location.     
  6765.                                                                       
  6766.      :                                                                
  6767.           No effect; the command does nothing.  A zero exit code      
  6768.           is returned.                                                
  6769.      . file                                                           
  6770.           Read and execute commands from file and return.  The        
  6771.           search path specified by PATH is used to find the           
  6772.           directory containing file.                                    
  6773.      break [ n ]                                                       
  6774.           Exit from the enclosing for or while loop, if any.  If      
  6775.           n is specified break n levels.                              
  6776.      continue [ n ]                                                  
  6777.           Resume the next iteration of the enclosing for or while    
  6778.           loop.  If n is specified resume at the nth enclosing       
  6779.           loop.                                                      
  6780.      cd [ arg ]                                                      
  6781.           Change the current directory to arg.  The shell             
  6782.           parameter HOME is the default arg.  The shell parameter     
  6783.           CDPATH defines the search path for the directory             
  6784.           containing arg.  Alternative directory names are             
  6785.           separated by a colon (:).  The default path is <null>        
  6786.           (specifying the current directory).  Note that the           
  6787.           current directory is specified by a null path name,          
  6788.           which can appear immediately after the equal sign or         
  6789.           between the colon delimiters anywhere else in the path     
  6790.           list.  If arg begins with a / the search path is not       
  6791.           used.  Otherwise, each directory in the path is             
  6792.           searched for arg.  The cd command may not be executed       
  6793.           by rsh.                                                     
  6794.      echo [ arg ... ]                                                 
  6795.           Echo arguments. See echo(1) for usage and description.      
  6796.      eval [ arg ... ]                                                 
  6797.           The arguments are read as input to the shell and the        
  6798.           resulting command(s) executed.                            
  6799.      exec [ arg ... ]                                                 
  6800.           The command specified by the arguments is executed in       
  6801.           place of this shell without creating a new process.         
  6802.           Input/output arguments may appear and, if no other          
  6803.           arguments are given, cause the shell input/output to be     
  6804.           modified.                                                   
  6805.      exit [ n ]                                                       
  6806.           Causes a shell to exit with the exit status specified       
  6807.           by n.  If n is omitted the exit status is that of the       
  6808.           last command executed (an end-of-file will also cause       
  6809.           the shell to exit.)                                          
  6810.      export [ name ... ]                                               
  6811.           The given names are marked for automatic export to the       
  6812.           environment of subsequently-executed commands.  If no        
  6813.           arguments are given, a list of all names that are            
  6814.           exported in this shell is printed.  (Variable names         
  6815.           exported from a parent shell are listed only if they        
  6816.           have been exported again during the current shell's         
  6817.           execution.) Function names may not be exported.             
  6818.      getopts                                                          
  6819.           Use in shell script to support command syntax standards     
  6820.           (see intro(1)); it parses positional parameters and         
  6821.           checks for legal options.  See getopts(1) for usage and     
  6822.           description.                                                
  6823.      hash [ -r ] [ name ... ]                                         
  6824.           For each name, the location in the search path of the       
  6825.           command specified by name is determined and remembered      
  6826.           by the shell.  The -r option causes the shell to forget     
  6827.           all remembered locations.  If no arguments are given,       
  6828.           information about remembered commands is presented.         
  6829.           hits is the number of times a command has been invoked      
  6830.           by the shell process.  cost is a measure of the work        
  6831.           required to locate a command in the search path.  If a
  6832.           command is found in a "relative" directory in the           
  6833.           search path, after changing to that directory, the          
  6834.           stored location of that command is recalculated.            
  6835.           Commands for which this will be done are indicated by       
  6836.           an asterisk (*) adjacent to the hits information.  cost     
  6837.           will be incremented when the recalculation is done.         
  6838.      newgrp [ arg ... ]                                               
  6839.           Equivalent to exec newgrp arg ....  See newgrp(1M) for      
  6840.           usage and description.                                      
  6841.      pwd                                                              
  6842.           Print the current working directory.  See pwd(1) for         
  6843.           usage and description.                                      
  6844.      read [ name ... ]                                                
  6845.           One line is read from the standard input and, using the     
  6846.           internal field separator, IFS (normally space or tab),     
  6847.           to delimit word boundaries, the first word is assigned     
  6848.           to the first name, the second word to the second name,     
  6849.           etc., with leftover words assigned to the last name.        
  6850.           Lines can be continued using \new-line.  Characters        
  6851.           other than new-line can be quoted by preceding them        
  6852.           with a backslash.  These backslashes are removed before     
  6853.           words are assigned to names, and no interpretation is       
  6854.           done on the character that follows the backslash.  The      
  6855.           return code is 0 unless an end-of-file is encountered.      
  6856.      readonly [ name ... ]                                            
  6857.           The given names are marked readonly and the values of       
  6858.           these names may not be changed by subsequent                
  6859.           assignment.  If no arguments are given, a list of all       
  6860.           readonly names is printed.                                  
  6861.      return [ n ]                                                      
  6862.           Causes a function to exit with the return value              
  6863.           specified by n.  If n is omitted, the return status is       
  6864.           that of the last command executed.                           
  6865.      set [ --aefhkntuvx [ arg ... ] ]                                 
  6866.           -a
  6867.  Mark variables which are modified or created for        
  6868.                export.                                   
  6869.           -e   Exit immediately if a command exits with a non-    
  6870.                zero exit status.                                  
  6871.           -f   Disable file name generation.                      
  6872.           -h   Locate and remember function commands as functions 
  6873.                are defined (function commands are normally           
  6874.                located when the function is executed).               
  6875.           -k   All keyword arguments are placed in the               
  6876.                environment for a command, not just those that        
  6877.                precede the command name.                              
  6878.           -n   Read commands but do not execute them.                 
  6879.           -t   Exit after reading and executing one command.          
  6880.           -u   Treat unset variables as an error when                 
  6881.                substituting.                                          
  6882.           -v   Print shell input lines as they are read.              
  6883.           -x   Print commands and their arguments as they are        
  6884.                executed.                                              
  6885.           --   Do not change any of the flags; useful in setting      
  6886.                $1 to -.                                              
  6887.           Using + rather than - causes these flags to be turned      
  6888.           off.  These flags can also be used upon invocation of      
  6889.           the shell.  The current set of flags may be found in       
  6890.           $-.  The remaining arguments are positional parameters       
  6891.           and are assigned, in order, to $1, $2, ....  If no           
  6892.           arguments are given the values of all names are           
  6893.           printed.                                                  
  6894.      shift [ n ]                                                    
  6895.           The positional parameters from $n+1 ... are renamed $1       
  6896.           ....  If n is not given, it is assumed to be 1.            
  6897.      test                                                            
  6898.           Evaluate conditional expressions. See test(1) for usage     
  6899.           and description.                                            
  6900.      times                                                            
  6901.           Print the accumulated user and system times for             
  6902.           processes run from the shell.                               
  6903.      trap [ arg ] [ n ] ...                                           
  6904.           The command arg is to be read and executed when the         
  6905.           shell receives signal(s) n.  (Note that arg is scanned      
  6906.           once when the trap is set and once when the trap is         
  6907.           taken.) Trap commands are executed in order of signal       
  6908.           number.  Any attempt to set a trap on a signal that was     
  6909.           ignored on entry to the current shell is ineffective.       
  6910.           An attempt to trap on signal 11 (memory fault) produces     
  6911.           an error.  If arg is absent all trap(s) n are reset to      
  6912.           their original values.  If arg is the null string this      
  6913.           signal is ignored by the shell and by the commands it       
  6914.           invokes.  If n is 0 the command arg is executed on exit     
  6915.           from the shell.  The trap command with no arguments         
  6916.           prints a list of commands associated with each signal       
  6917.           number.                                                     
  6918.      type [ name ... ]                                                
  6919.           For each name, indicate how it would be interpreted if      
  6920.           used as a command name.                                     
  6921.      ulimit [ n ]                                                     
  6922.           Impose a size limit of n blocks on files written by the     
  6923.           shell and its child processes (files of any size may be     
  6924.           read).  If n is omitted, the current limit is printed.      
  6925.           Each user may lower the ulimit, but only a super-user       
  6926.           (see su(1M)) can raise a ulimit.                            
  6927.      umask [ nnn ]                                                    
  6928.           The user file-creation mask is set to nnn (see              
  6929.           umask(1)).  If nnn is omitted, the current value of the     
  6930.           mask is printed.                                            
  6931.      unset [ name ... ]                                               
  6932.           For each name, remove the corresponding variable or         
  6933.           function.  The variables PATH, PS1, PS2, MAILCHECK and      
  6934.           IFS cannot be unset.                                        
  6935.      wait [ n ]                                                       
  6936.           Wait for a background process whose process ID is n and     
  6937.           report its termination status.  If n is omitted, all        
  6938.           the shell's currently active background processes are       
  6939.           waited for and the return code will be zero.                
  6940.                                                                      
  6941.    Invocation                                                        
  6942.      If the shell is invoked through exec(2) and the first           
  6943.      character of argument zero is -, commands are initially read    
  6944.      from /etc/profile and from $HOME/.profile, if such files        
  6945.      exist.  Thereafter, commands are read as described below,       
  6946.      which is also the case when the shell is invoked as /bin/sh.    
  6947.      The flags below are interpreted by the shell on invocation      
  6948.      only.  Note that unless the -c or -s flag is specified, the     
  6949.      first argument is assumed to be the name of a file              
  6950.      containing commands, and the remaining arguments are passed     
  6951.      as positional parameters to that command file:                  
  6952.                                                                       
  6953.      -c string If the -c flag is present commands are read from       
  6954.                string.                                                
  6955.      -s        If the -s flag is present or if no arguments           
  6956.                remain commands are read from the standard input.      
  6957.                Any remaining arguments specify the positional         
  6958.                parameters.  Shell output (except for Special          
  6959.                Commands) is written to file descriptor 2.             
  6960.      -i        If the -i flag is present or if the shell input        
  6961.                and output are attached to a terminal, this shell      
  6962.                is interactive.  In this case TERMINATE is ignored     
  6963.                (so that kill 0 does not kill an interactive           
  6964.                shell) and INTERRUPT is caught and ignored (so         
  6965.                that wait is interruptible).  In all cases, QUIT       
  6966.                is ignored by the shell.                               
  6967.      -r        If the -r flag is present the shell is a
  6968.                restricted shell.                       
  6969.                                                                      
  6970.      The remaining flags and arguments are described under the       
  6971.      set command above.                                              
  6972.                                                                      
  6973.    rsh Only                                                          
  6974.      rsh is used to set up login names and execution environments    
  6975.      whose capabilities are more controlled than those of the        
  6976.      standard shell.  The actions of rsh are identical to those       
  6977.      of sh, except that the following are disallowed:                 
  6978.                                                                       
  6979.           changing directory (see cd(1)),                             
  6980.           setting the value of $PATH,                                 
  6981.           specifying path or command names containing /,              
  6982.           redirecting output (> and >>).                              
  6983.                                                                       
  6984.      The restrictions above are enforced after .profile is            
  6985.      interpreted.                                                     
  6986.                                                                       
  6987.      A restricted shell can be invoked in one of the following        
  6988.      ways: (1) rsh is the file name part of the last entry in the     
  6989.      /etc/passwd file (see passwd(4)); (2) the environment            
  6990.      variable SHELL exists and rsh is the file name part of its       
  6991.      value; (3) the shell is invoked and rsh is the file name         
  6992.      part of argument 0; (4) the shell is invoked with the -r         
  6993.      option.                                                          
  6994.                                                                       
  6995.      When a command to be executed is found to be a shell             
  6996.      procedure, rsh invokes sh to execute it.  Thus, it is            
  6997.      possible to provide to the end-user shell procedures that        
  6998.      have access to the full power of the standard shell, while       
  6999.      imposing a limited menu of commands; this scheme assumes         
  7000.      that the end-user does not have write and execute                
  7001.      permissions in the same directory.                               
  7002.                                                                       
  7003.      The net effect of these rules is that the writer of the          
  7004.      .profile has complete control over user actions, by              
  7005.      performing guaranteed setup actions and leaving the user in      
  7006.      an appropriate directory (probably not the login directory).     
  7007.                                                                       
  7008.      The system administrator often sets up a directory of            
  7009.      commands (i.e., /usr/rbin) that can be safely invoked by         
  7010.      rsh.  Some systems also provide a restricted editor red.         
  7011.                                                                       
  7012. EXIT STATUS                                                           
  7013.      Errors detected by the shell, such as syntax errors, cause       
  7014.      the shell to return a non-zero exit status.  If the shell is     
  7015.      being used non-interactively execution of the shell file is      
  7016.      abandoned.  Otherwise, the shell returns the exit status of      
  7017.      the last command executed (see also the exit command above).     
  7018.                                                                       
  7019. FILES                                                                 
  7020.      /etc/profile                                                     
  7021.      $HOME/profile                                                    
  7022.      /tmp/sh*                                                         
  7023.      /dev/null                                                        
  7024.                                                                       
  7025. SEE ALSO                                                              
  7026.      acctcom(1), cd(1), echo(1), env(1), ksh(1), login(1),            
  7027.      pwd(1), test(1), umask(1).                                       
  7028.      acctcms(1M), newgrp(1M), su(1M) in the UMAX V                    
  7029.      Administrator's Reference Manual.                                
  7030.      dup(2), exec(2), fork(2), pipe(2), signal(2), ulimit(2),         
  7031.      wait(2), a.out(4), passwd(4), profile(4), environ(5) in the      
  7032.      UMAX V Programmer's Reference Manual.                            
  7033.                                                                       
  7034. CAVEATS                                                               
  7035.      Words used for filenames in input/output redirection are not     
  7036.      interpreted for filename generation (see File Name               
  7037.      Generation, above).  For example, cat file1 > a* will create     
  7038.      a file named a*.                                                 
  7039.                                                                       
  7040.      Because commands in pipelines are run as separate processes,     
  7041.      variables set in a pipeline have no effect on the parent         
  7042.      shell.                                                           
  7043.                                                                       
  7044.      If the error message cannot fork, too many processes is          
  7045.      displayed, try using the wait(1) command to clean up the         
  7046.      background processes.  If this does not help, the system         
  7047.      process table is probably full or there are too many active      
  7048.      foreground processes.  (There is a limit to the number of        
  7049.      process IDs associated with a login and to the number of         
  7050.      which the system can keep track.)                                
  7051. BUGS                                                                  
  7052.      If a command is executed, and a command with the same name       
  7053.      is installed in a directory in the search path before the        
  7054.      directory where the original command was found, the shell        
  7055.      will continue to exec the original command.  Use the hash        
  7056.      command to correct this situation.                               
  7057.                                                                       
  7058.      If the current directory or one above it is moved, pwd may       
  7059.      not give the correct response.  Use the cd command with a
  7060.      full path name to correct this situation.                        
  7061.                                                                       
  7062.      Not all the processes of a 3- or more-stage pipeline are         
  7063.      children of the shell, and thus cannot be waited for.            
  7064.                                                                       
  7065.      For wait n, if n is not an active process id, all the            
  7066.      shell's currently active background processes are waited for     
  7067.      and the return code will be zero.                          
  7068.     
  7069.                                   NOTES
  7070. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  7071. APPENDIX B - test
  7072.  
  7073.  
  7074. $man test                                                             
  7075.                                                                       
  7076. NAME                                                                  
  7077.      test - condition evaluation command                              
  7078.                                                                       
  7079. SYNOPSIS                                                              
  7080.      test expr                                                        
  7081.      [ expr ]                                                         
  7082.                                                                       
  7083. DESCRIPTION                                                           
  7084.      test evaluates the expression expr and, if its value is          
  7085.      true, returns a zero (true) exit status; otherwise, a non-       
  7086.      zero (false) exit status is returned; test also returns a
  7087.      non-zero exit status if there are no arguments.  When            
  7088.      permissions are tested, the effective user ID of the process     
  7089.      is used.                                                         
  7090.                                                                       
  7091.      All operators, flags, and brackets (brackets used as shown       
  7092.      in the second SYNOPSIS line) must be separate arguments to       
  7093.      the test command; normally these items are separated by          
  7094.      spaces.                                                          
  7095.                                                                       
  7096.      The following primitives are used to construct expr:             
  7097.                                                                       
  7098.      -r file     true if file exists and is readable.                 
  7099.                                                                       
  7100.      -w file     true if file exists and is writable.                 
  7101.                                                                       
  7102.      -x file     true if file exists and is executable.               
  7103.                                                                       
  7104.      -f file     true if file exists and is a regular file.           
  7105.                                                                       
  7106.      -d file     true if file exists and is a directory.              
  7107.                                                                       
  7108.      -c file     true if file exists and is a character special       
  7109.                  file.                                                
  7110.                                                                       
  7111.      -b file     true if file exists and is a block special file.     
  7112.                                                                       
  7113.      -p file     true if file exists and is a named pipe (fifo).      
  7114.                                                                       
  7115.      -u file     true if file exists and its set-user-ID bit is       
  7116.                  set.                                                 
  7117.                                                                       
  7118.      -g file     true if file exists and its set-group-ID bit is      
  7119.                  set.                                                 
  7120.                                                                       
  7121.      -k file     true if file exists and its sticky bit is set.       
  7122.                                                                       
  7123.      -s file     true if file exists and has a size greater than      
  7124.                  zero.                                                
  7125.                                                                       
  7126.      -t [ fildes ]                                                    
  7127.                  true if the open file whose file descriptor          
  7128.                  number is fildes (1 by default) is associated        
  7129.                  with a terminal device.                              
  7130.                                                                       
  7131.      -z s1       true if the length of string s1 is zero.             
  7132.                                                                       
  7133.      -n s1       true if the length of the string s1 is non-zero.     
  7134.                                                                       
  7135.      s1 =  s2    true if strings s1 and s2 are identical.             
  7136.                                                                       
  7137.      s1 != s2    true if strings s1 and s2 are not identical.         
  7138.                                                                       
  7139.      s1          true if s1 is not the null string.                   
  7140.                                                                       
  7141.      n1 -eq n2   true if the integers n1 and n2 are algebraically     
  7142.                  equal.  Any of the comparisons -ne, -gt, -ge,        
  7143.                  -lt, and -le may be used in place of -eq.            
  7144.                                                                       
  7145.      These primaries may be combined with the following               
  7146.      operators:                                                       
  7147.                                                                       
  7148.      !           unary negation operator.                             
  7149.                                                                       
  7150.      -a
  7151.         binary and operator.                                 
  7152.                                                              
  7153.      -o          binary or operator (-a has higher precedence
  7154.                  than -o).                                   
  7155.                                                              
  7156.      ( expr )    parentheses for grouping.  Notice that      
  7157.                  parentheses are meaningful to the shell and,
  7158.                  therefore, must be escaped.                 
  7159.                                                                       
  7160. SEE ALSO                                                              
  7161.      csh(1), find(1), ksh(1), sh(1).                                  
  7162.                                                                       
  7163. WARNING                                                               
  7164.      If a user tests a file (using -r, -w, or -x), but the            
  7165.      permission tested does not have the owner bit set, a non-        
  7166.      zero (false) exit status will be returned even though the        
  7167.      file may have the group or other bit set for that                
  7168.      permission. The correct exit status will be set if the user      
  7169.      is super-user.                                                   
  7170.                                                                       
  7171.      The = and != operators have a higher precedence than the -r      
  7172.      through -n operators, and = and != always expect arguments;      
  7173.      therefore, = and != cannot be used with the -r through -n        
  7174.      operators.                                                       
  7175.                                                                       
  7176.      If more than one argument follows the -r through -n              
  7177.      operators, only the first argument is examined; the others       
  7178.      are ignored, unless a -a or a -o is the second argument.         
  7179.                                                                       
  7180.      In the second form of the command (i.e., the one that uses       
  7181.      [], rather than the word test), the square brackets must be      
  7182.      delimited by blanks.         
  7183.                                     
  7184.                                NOTES
  7185. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  7186. APPENDIX C - expr                                                       
  7187.                                                                         
  7188.  
  7189. $man expr                                                             
  7190. NAME                                                                  
  7191.      expr - evaluate arguments as an expression                       
  7192.                                                                       
  7193. SYNOPSIS                                                              
  7194.      expr arguments                                                   
  7195.                                                                       
  7196. DESCRIPTION                                                           
  7197.      The arguments are taken as an expression.  After evaluation,     
  7198.      the result is written on the standard output.  Terms of the      
  7199.      expression must be separated by blanks.  Characters special      
  7200.      to the shell must be escaped.  Note that 0 is returned to        
  7201.      indicate a zero value, rather than the null string.  Strings     
  7202.      containing blanks or other special characters should be          
  7203.      quoted.  Integer-valued arguments may be preceded by a unary     
  7204.      minus sign.  Internally, integers are treated as 32-bit, 2s      
  7205.      complement numbers.                                              
  7206.                                                                       
  7207.      The operators and keywords are listed below.  Characters         
  7208.      that need to be escaped are preceded by \.  The list is in       
  7209.      order of increasing precedence, with equal precedence            
  7210.      operators grouped within {} symbols.                             
  7211.                                                                       
  7212.      expr \ | expr  returns the first expr if it is neither null      
  7213.                     nor 0, otherwise returns the second expr.         
  7214.                                                                       
  7215.      expr \& expr   returns the first expr if neither expr is         
  7216.                     null nor 0, otherwise returns 0.                  
  7217.                                                                       
  7218.      expr { =, \>, \, \<, \, != } expr                                
  7219.                     returns the result of an integer comparison       
  7220.                     if both arguments are integers, otherwise         
  7221.                     returns the result of a lexical comparison.       
  7222.                                                                       
  7223.      expr { +, - } expr                                               
  7224.                     addition or subtraction of integer-valued         
  7225.                     arguments.                                        
  7226.                                                                       
  7227.      expr { \*, /, % } expr                                           
  7228.                     multiplication, division, or remainder of the     
  7229.                     integer-valued arguments.                         
  7230.                                                                       
  7231.      expr : expr    The matching operator : compares the first        
  7232.                     argument with the second argument which must      
  7233.                     be a regular expression.  Regular expression      
  7234.                     syntax is the same as that of ed(1), except       
  7235.                     matching operator returns the number of           
  7236.                     characters matched (0 on failure).                
  7237.                     Alternatively, the \(...\) pattern symbols        
  7238.                     can be used to return a portion of the first      
  7239.                     argument.                                         
  7240.                                                                       
  7241. EXAMPLES                                                              
  7242.      1.   a=`expr $a + 1`                                             
  7243.           adds 1 to the shell variable                                
  7244.                                                                       
  7245.      2.   #  For $a equal to either "/usr/abc/file" or just           
  7246.           "file"                                                      
  7247.           expr $a : '.*/\(.*\)' \| $a
  7248.                                  ‡
  7249.           returns the last segment of a path name (i.e., file).        
  7250.           Watch out for / alone as an argument:  expr will take        
  7251.           it as the division operator (see BUGS below).                
  7252.                                                                        
  7253.      3.   #  A better representation of the previous example.          
  7254.           expr //$a : '.*/\(.*\)'                                      
  7255.           The addition of the // characters eliminates any             
  7256.           ambiguity about the division operator and simplifies         
  7257.           the whole expression.                                        
  7258.                                                                        
  7259.      4.   expr $VAR :  '.*'                                            
  7260.           returns the number of characters in $VAR.                    
  7261.                                                                        
  7262. SEE ALSO                                                               
  7263.      ed(1), sh(1).                                                     
  7264.                                                                        
  7265. DIAGNOSTICS                                                            
  7266.      As a side effect of expression evaluation, expr returns the       
  7267.      following exit values:                                            
  7268.      0    if the expression is neither null nor 0                      
  7269.      1    if the expression is null or 0                               
  7270.      2    for invalid expressions.                                     
  7271.                                                                        
  7272.      syntax error                                                      
  7273.           for operator/operand errors                                  
  7274.      non-numeric argument                                              
  7275.           if arithmetic is attempted on such a string                  
  7276.                                                                        
  7277. BUGS                                                                   
  7278.      After argument processing by the shell, expr cannot tell the      
  7279.      difference between an operator and an operand except by the       
  7280.      value.  If $a is an =, the command:  expr  $a = '=' looks         
  7281.      like:  expr = = = as the arguments are passed to expr (and        
  7282.      they will all be taken as the = operator).  The following         
  7283.      works:  expr  X$a = X=                                            
  7284. APPENDIX D - ftp
  7285.  
  7286.  
  7287. $man ftp                                                               
  7288.                                                                        
  7289. NAME                                                                   
  7290.      ftp - Internet file transfer program                              
  7291.                                                                        
  7292. SYNOPSIS                                                               
  7293.      ftp [ -v ] [ -d ] [ -i ] [ -n ] [ -g ] [ host ]                   
  7294.                                                                        
  7295. DESCRIPTION                                                            
  7296.      ftp is the user interface to the DARPA File Transfer              
  7297.      Protocol. The program transfers files to and from a remote        
  7298.      network site.                                                     
  7299.                                                                        
  7300.      The client host with which ftp is to communicate can be           
  7301.      specified on the command line. In this case, ftp immediately      
  7302.      attempts to establish a connection to an FTP server on that       
  7303.      host; otherwise, ftp enters its command interpreter and           
  7304.      waits for instruction, displaying the prompt ftp>.                
  7305.                                                                        
  7306.      ftp recognizes the following commands:                            
  7307.                                                                        
  7308.      ! [ command [ args ] ]                                            
  7309.                Invoke an interactive shell on the local machine.       
  7310.                If there are arguments, the first is taken to be a
  7311.                command to execute directly, with the rest of the       
  7312.                arguments as its arguments.                             
  7313.                                                                        
  7314.      $ macro-name [ args ]                                             
  7315.                Execute the macro-name that was defined with     
  7316.                the macdef command.  Arguments are passed to the 
  7317.                macro unglobbed.                                 
  7318.                                                                 
  7319.      account [ passwd ]                                         
  7320.                Supply a supplemental password required by a
  7321.                remote system for access to resources once a login      
  7322.                has been successfully completed.  If no argument        
  7323.                is included, the user will be prompted for an           
  7324.                account password in a non-echoing input mode.           
  7325.                                                                        
  7326.      append local-file [ remote-file ]                                 
  7327.                Append a local file to a file on the remote             
  7328.                machine. If remote-file is left unspecified, the        
  7329.                local file name is used to name the remote file         
  7330.                after being altered by any ntrans or nmap setting.      
  7331.                File transfer uses the current settings for type,       
  7332.                format, mode, and structure.                            
  7333.                                                                        
  7334.      ascii     Set the file transfer type to network ASCII. This       
  7335.                is the default type.                                    
  7336.                                                                        
  7337.      bell      Sound a bell after each file transfer command is        
  7338.                completed.                                              
  7339.                                                                        
  7340.      binary    Set the file transfer type to support binary image      
  7341.                transfer.                                               
  7342.                                                                        
  7343.      bye       Terminate the FTP session with the remote server        
  7344.                and exit ftp.                                           
  7345.                                                                        
  7346.      case      Toggle remote computer file name case mapping           
  7347.                during mget commands.  When case is on (default is      
  7348.                off), remote computer file names with all letters       
  7349.                in upper case are written in the local directory        
  7350.                with the letters mapped to lower case.                  
  7351.                                                                        
  7352.      cd remote-directory                                               
  7353.                Change the working directory on the remote machine      
  7354.                to remote-directory.                                    
  7355.                                                                        
  7356.      cdup      Change the remote machine working directory to the     
  7357.                parent of the current remote machine working           
  7358.                directory.                                             
  7359.                                                                       
  7360.      close     Terminate the FTP session with the remote server,      
  7361.                and return to the command interpreter.  Any            
  7362.                defined macros are erased.                             
  7363.                                                                       
  7364.      cr        Toggle carriage return stripping during ASCII type     
  7365.                file retrieval.  Records are denoted by a carriage     
  7366.                return/linefeed sequence during ASCII type file        
  7367.                transfer.  When cr is on (the default), carriage       
  7368.                returns are stripped from this sequence to conform     
  7369.                with the UNIX single linefeed record delimiter.        
  7370.                Records on non-UNIX remote systems may contain         
  7371.                single linefeeds; when an ASCII type transfer is       
  7372.                made, these linefeeds may be distinguished from a
  7373.                record delimiter only when cr is off.                  
  7374.                                                                       
  7375.      delete remote-file                                               
  7376.                Delete the file remote-file on the remote machine.     
  7377.                                                                       
  7378.      debug [ debug-value ]                                            
  7379.                Toggle debugging mode. If an optional debug-value      
  7380.                is specified, it is used to set the debugging          
  7381.                level. When debugging is on, ftp prints each           
  7382.                command sent to the remote machine, preceded by        
  7383.                the string --> .                                       
  7384.                                                                       
  7385.      dir [ remote-directory ] [ local-file ]                          
  7386.                Print the contents of directory, remote-directory,     
  7387.                and, optionally, place the output in local-file.       
  7388.                If no directory is specified, the current working      
  7389.                directory on the remote machine is used. If no         
  7390.                local file is specified, or local-file is -,           
  7391.                output comes to the terminal.                          
  7392.                                                                       
  7393.      disconnect                                                       
  7394.                A synonym for close.                                   
  7395.                                                                       
  7396.      form format                                                      
  7397.                Set the file transfer form to format.  The default      
  7398.                format is file.                                         
  7399.                                                                        
  7400.      get remote-file [ local-file ]                                    
  7401.                Retrieve the remote-file and store it on the local      
  7402.                machine. If the local file name is not specified,       
  7403.                it is given the same name it has on the remote          
  7404.                machine, subject to alteration by the current           
  7405.                case, ntrans, and nmap settings. The current            
  7406.                settings for type, form, mode, and structure are        
  7407.                used while transferring the file.                       
  7408.                                                                        
  7409.      glob      Toggle filename expansion for mdelete, mget and         
  7410.                mput.  If globbing is turned off with glob, the         
  7411.                file name arguments are taken literally and not         
  7412.                expanded.  Globbing for mput is done as in csh(1).      
  7413.                For mdelete and mget, each remote file name is          
  7414.                expanded separately on the remote machine and the       
  7415.                lists are not merged.  Expansion of a directory         
  7416.                name is likely to be different from expansion of        
  7417.                the name of an ordinary file:  the exact result         
  7418.                depends on the foreign operating system and FTP         
  7419.                server, and can be previewed by doing                   
  7420.                "mls remote-files -".  Note:  mget and mput are         
  7421.                not meant to transfer entire directory subtrees of      
  7422.                files.  That can be done by transferring a tar(1)       
  7423.                archive of the subtree (in binary mode).                
  7424.                                                                        
  7425.      hash      Toggle number-sign (#) printing for each data
  7426.                block transferred. The size of a data block i
  7427.                1024 bytes.                                  
  7428.                                                                       
  7429.      help [ command ]                                                 
  7430.                Print a description of command.  With no argument,     
  7431.                ftp prints a list of the known commands.               
  7432.                                                                       
  7433.      lcd [ directory ]                                                
  7434.                Change the working directory on the local machine.     
  7435.                If no directory is specified, changes to the          
  7436.                user's home directory.                                
  7437.                                                                      
  7438.      ls [ remote-directory ] [ local-file ]                          
  7439.                Print an abbreviated listing of the contents of a
  7440.                directory on the remote machine. If remote-           
  7441.                directory is left unspecified, the current working    
  7442.                directory is used. If no local file is specified,     
  7443.                the output is sent to the terminal.                   
  7444.                                                                      
  7445.      macdef macro-name                                               
  7446.                Define a macro.  Subsequent lines are stored as       
  7447.                the macro-name; a null line (consecutive        
  7448.                newline characters in a file or carriage returns      
  7449.                from the terminal) terminates macro input mode.       
  7450.                There is a limit of 16 macros and 4096 total          
  7451.                characters in all defined macros.  Macros remain      
  7452.                defined until a close command is executed.  The       
  7453.                macro processor interprets "$" and "\" as special     
  7454.                characters.  A "$" followed by a number (or           
  7455.                numbers) is replaced by the corresponding argument    
  7456.                on the macro invocation command line.  A "$"          
  7457.                followed by an "i" signals that macro processor       
  7458.                that the executing macro is to be looped. On the      
  7459.                first pass "$i" is replaced by the first argument     
  7460.                on the macro invocation command line, on the          
  7461.                second pass it is replaced by the second argument,    
  7462.                and so on.  A "\" followed by any character is        
  7463.                replaced by that character.  Use the "\" to           
  7464.                prevent special treatment of the "$".                 
  7465.                                                                      
  7466.      mdelete [ remote-files ]                                        
  7467.                Delete the specified files on the remote machine.     
  7468.                                                                      
  7469.      mdir remote-files local-file                                    
  7470.                Like dir, except multiple remote files may be         
  7471.                specified.  If interactive prompting is on, ftp       
  7472.                will prompt the user to verify that the last          
  7473.                argument is indeed the target local file for          
  7474.                receiving mdir output.                                
  7475.                                                                      
  7476.      mget remote-files                                                
  7477.                Expand the remote-files on the remote machine and      
  7478.                do a get for each file name thus produced.  See        
  7479.                glob for details on the filename expansion.            
  7480.                Resulting file names will then be processed            
  7481.                according to case, ntrans, and nmap settings.          
  7482.                Files are transferred into the local working           
  7483.                directory, which can be changed with                   
  7484.                "lcd directory"; new local directories can be          
  7485.                created with "! mkdir directory".                      
  7486.                                                                       
  7487.      mkdir directory-name                                             
  7488.                Make a directory on the remote machine.                
  7489.                                                                       
  7490.      mls remote-files local-file                                       
  7491.                Like ls, except multiple remote files may be            
  7492.                specified.  If interactive prompting is on, ftp         
  7493.                will prompt the user to verify that the last            
  7494.                argument is indeed the target local file for            
  7495.                receiving mls output.                                   
  7496.                                                                        
  7497.      mode [ mode-name ]                                                
  7498.                Set the file transfer mode to mode-name.  The           
  7499.                default mode is stream.                                 
  7500.                                                                        
  7501.      mput local-files                                                  
  7502.                Expand wild cards in the list of local files given      
  7503.                as arguments and do a put for each file in the         
  7504.                resulting list.  See glob for details of filename      
  7505.                expansion.  Resulting file names will then be          
  7506.                processed according to ntrans and nmap settings.       
  7507.                                                                       
  7508.      nmap [ inpattern outpattern ]                                     
  7509.                Set or unset the filename mapping mechanism.  If        
  7510.                no arguments are specified, the filename mapping        
  7511.                mechanism is unset.  If arguments are specified,        
  7512.                remote filenames are mapped during mput commands        
  7513.                and put commands issued without a specified remote      
  7514.                target filename.  If arguments are specified,           
  7515.                local filenames are mapped during mget commands         
  7516.                and get commands issued without a specified local       
  7517.                target filename.  This command is useful when           
  7518.                connecting to a non-UNIX remote computer with           
  7519.                different file naming conventions or practices.         
  7520.                The mapping follows the pattern set by inpattern        
  7521.                and outpattern.  inpattern is a template for            
  7522.                incoming filenames (which may have already been         
  7523.                processed according to the ntrans and case              
  7524.                settings).  Variable templating is accomplished by      
  7525.                including the sequences "$1", "$2", ..., "$9" in        
  7526.                inpattern.  Use "\" to prevent this special             
  7527.                treatment of the "$" character.  All other              
  7528.                characters are treated literally, and are used to       
  7529.                determine the nmap inpattern variable values.  For      
  7530.                example, given inpattern $1.$2 and the remote file      
  7531.                name mydata.data, $1 would have the value mydata,       
  7532.                and $2 would have the value data.  The outpattern       
  7533.                determines the resulting mapped filename.  The          
  7534.                sequences "$1", "$2", ..., "$9" are replaced by         
  7535.                any value resulting from the inpattern template.        
  7536.                The sequence "$0" is replaced by the original           
  7537.                filename.  Additionally, the sequence                   
  7538.                "[seq1,seq2]" is replaced by seq1 if seq1 is not a
  7539.                null string; otherwise it is replaced by seq2.          
  7540.                For example, the command "nmap $1.$2.$3                 
  7541.                [$1,$2].[$2,file]" would yield the output filename      
  7542.                myfile.data for input filenames myfile.data and         
  7543.                myfile.data.old, myfile.file for the input              
  7544.                filename myfile, and myfile.myfile for the input        
  7545.                filename .myfile.  Spaces may be included in            
  7546.                outpattern, as in the example:                          
  7547.                                                                        
  7548.                     nmap $1 | sed "s/  *$//" > $1                      
  7549.                                                                        
  7550.                Use the "\" character to prevent special treatment      
  7551.                of the "$", "[", "]", and "," characters.               
  7552.                                                                        
  7553.      ntrans [ inchars [ outchars ] ]                                   
  7554.                Set or unset the filename character translation         
  7555.                mechanism.  If no arguments are specified, the          
  7556.                filename character translation mechanism is unset.      
  7557.                If arguments are specified, characters in remote        
  7558.                filenames are translated during mput commands and       
  7559.                put commands issued without a specified remote          
  7560.                target filename.  If arguments are specified,           
  7561.                characters in local filenames are translated            
  7562.                during mget commands and get commands issued            
  7563.                without a specified local target filename.  This        
  7564.                command is useful when connecting to a non-UNIX         
  7565.                remote computer with different file naming              
  7566.                conventions or practices.  Characters in a
  7567.                filename matching a character in inchars are            
  7568.                replaced with the corresponding character in            
  7569.                outchars.  If the character's position in inchars       
  7570.                is longer than the length of outchars, the              
  7571.                character is deleted from the file name.                
  7572.                                                                        
  7573.      open host [ port ]                                                
  7574.                Establish a connection to the specified host's FTP      
  7575.                server. An optional port number can be supplied,        
  7576.                in which case, ftp attempts to contact an FTP           
  7577.                server at that port. If the auto-login option is        
  7578.                on (default), ftp also attempts to automatically        
  7579.                log the user in to the FTP server (see below).          
  7580.                                                                        
  7581.      prompt    Toggle interactive prompting. Interactive               
  7582.                prompting occurs during multiple file transfers to      
  7583.                allow the user to selectively retrieve or store         
  7584.                files. If prompting is turned off (default), any        
  7585.                mget or mput transfers all files and mdelete will       
  7586.                delete all files.                                       
  7587.                                                                        
  7588.      proxy ftp-command                                                 
  7589.                Execute an ftp command on a secondary control           
  7590.                connection.  This command allows simultaneous           
  7591.                connection to two remote FTP servers for                
  7592.                transferring files between the two servers.  The        
  7593.                first proxy command should be an open, to               
  7594.                establish the secondary control connection.  Enter      
  7595.                the command "proxy ?" to see other ftp commands         
  7596.                executable on the secondary connection.  The            
  7597.                following commands behave differently when              
  7598.                prefaced by proxy:  open will not define new            
  7599.                macros during the auto-login process, close will        
  7600.                not erase existing macro definitions, get and mget      
  7601.                transfer files from the host on the primary             
  7602.                control connection to the host on the secondary         
  7603.                control connection, and put, mput, and append           
  7604.                transfer files from the host on the secondary           
  7605.                control connection to the host on the primary           
  7606.                control connection.  Third party file transfers         
  7607.                depend upon support of the FTP protocol PASV            
  7608.                command by the server on the secondary control          
  7609.                connection.                                             
  7610.                                                                        
  7611.      put local-file [ remote-file ]                                    
  7612.                Store a local file on the remote machine. If            
  7613.                remote-file is left unspecified, the local file         
  7614.                name is used in naming the remote file, after           
  7615.                processing according to any ntrans or nmap              
  7616.                settings.  File transfer uses the current settings      
  7617.                for type, format, mode, and structure.                  
  7618.                                                                        
  7619.      pwd       Print the name of the current working directory on      
  7620.                the remote machine.                                     
  7621.                                                                        
  7622.      quit      A synonym for bye.                                      
  7623.                                                                        
  7624.      quote arg1 arg2 ...                                               
  7625.                The arguments specified are sent, verbatim, to the      
  7626.                remote FTP server.                                      
  7627.                                                                        
  7628.      recv remote-file [ local-file ]                                   
  7629.                A synonym for get.                                      
  7630.                                                                        
  7631.      remotehelp [ command-name ]                                       
  7632.                Request help from the remote FTP server. If a
  7633.                command-name is specified, it is supplied to the       
  7634.                server as well.                                        
  7635.                                                                       
  7636.      rename [ from ] [ to ]                                           
  7637.                Rename, on the remote machine, the file from to        
  7638.                the file to.                                           
  7639.                                                                       
  7640.      reset     Clear reply queue.  This command re-synchronizes       
  7641.                command/reply sequencing with the remote FTP           
  7642.                server.  Resynchronization may be necessary            
  7643.                following a violation of the FTP protocol by the       
  7644.                remote server.                                         
  7645.                                                                       
  7646.      rmdir directory-name                                             
  7647.                Delete a directory on the remote machine.              
  7648.                                                                       
  7649.      runique   Toggle storing of files on the local system with       
  7650.                unique filenames.  If a file already exists with a
  7651.                name equal to the target local filename for a get       
  7652.                or mget command, a ".1" is appended to the name.        
  7653.                If the resulting name matches another existing          
  7654.                file, a ".2" is appended to the original name.  If      
  7655.                this process continues up to ".99", an error            
  7656.                message is printed, and the transfer does not take      
  7657.                place.  The generated unique filename will be           
  7658.                reported.  Note that runique will not affect local      
  7659.                files generated from a shell command (see below).       
  7660.                The default value is off.                               
  7661.                                                                        
  7662.      send local-file [ remote-file ]                                   
  7663.                A synonym for put.                                      
  7664.                                                                        
  7665.      sendport  Toggle the use of PORT commands. By default, ftp        
  7666.                attempts to use a PORT command when establishing a
  7667.                connection for each data transfer. The use of PORT      
  7668.                commands can prevent delays when performing             
  7669.                multiple file transfers.  If the PORT command           
  7670.                fails, ftp uses the default data port. When the         
  7671.                use of PORT commands is disabled, no attempt is         
  7672.                made to use them for each data transfer. This is        
  7673.                useful for certain FTP implementations that do          
  7674.                ignore PORT commands but wrongly indicate they          
  7675.                have been accepted.                                     
  7676.                                                                        
  7677.      status    Show the current status of ftp.                          
  7678.                                                                         
  7679.      struct [ struct-name ]                                             
  7680.                Set the file transfer structure to struct-name.          
  7681.                The default structure is stream.                         
  7682.                                                                         
  7683.      sunique   Toggle storing of files on remote machine under        
  7684.                unique file names.  Remote FTP server must support     
  7685.                the FTP protocol STOU command for successful           
  7686.                completion.  The remote server will report a
  7687.                unique name.  Default value is off.                    
  7688.                                                                       
  7689.      tenex     Set the file transfer type to that needed to talk      
  7690.                to TENEX machines.                                     
  7691.                                                                       
  7692.      trace     Toggle packet tracing.                                 
  7693.                                                                       
  7694.      type [ type-name ]                                               
  7695.                Set the file transfer type to type-name.  If no        
  7696.                type-name is specified, the current type is            
  7697.                printed. The default type is network ascii.            
  7698.                                                                       
  7699.      user user-name [ password ] [ account ]                          
  7700.                The user identifies him/herself to the remote FTP      
  7701.                server. If the password is not specified and the       
  7702.                server requires it, ftp prompts the user for it        
  7703.                (after disabling local echo).  If an account field     
  7704.                is not specified, and the FTP server requires it,      
  7705.                the user is prompted for it. If an account field       
  7706.                is specified, an account command will be relayed       
  7707.                to the remote server after the login sequence is       
  7708.                completed if the remote server did not require it      
  7709.                for logging in.  Unless ftp is invoked with            
  7710.                "auto-login" disabled, this process is done            
  7711.                automatically on initial connection to the FTP         
  7712.                server.                                                
  7713.                                                                       
  7714.      verbose   Toggle verbose mode. In verbose mode, all              
  7715.                responses from the FTP server are displayed to the     
  7716.                user. In addition, if verbose is on, when a file       
  7717.                transfer completes, statistics regarding the           
  7718.                efficiency of the transfer are reported. By            
  7719.                default, verbose is on.                                
  7720.                                                                       
  7721.      ? [ command ]                                                    
  7722.                A synonym for help.                                    
  7723.                                                                       
  7724.      Command arguments that have embedded spaces can be quoted        
  7725.      with double quote (") marks.                                     
  7726.                                                                       
  7727. ABORTING A FILE TRANSFER                                              
  7728.      To abort a file transfer, use the terminal interrupt key         
  7729.      (usually <ctrl>C).  Sending transfers will be immediately        
  7730.      halted.  Receiving transfers will be halted by sending a FTP     
  7731.      protocol ABOR command to the remote server, and discarding       
  7732.      any further data received.  The speed at which this is           
  7733.      accomplished depends upon the remote server's support for        
  7734.      ABOR processing.  If the remote server does not support the      
  7735.      ABOR command, an ftp> prompt will not appear until the           
  7736.      remote server has completed sending the requested file.          
  7737.                                                                       
  7738.      The terminal interrupt key sequence will be ignored when ftp     
  7739.      has completed any local processing and is awaiting a reply       
  7740.      from the remote server.  A long delay in this mode may           
  7741.      result from the ABOR processing described above, or from         
  7742.      unexpected behavior by the remote server, including              
  7743.      violations of the FTP protocol.  If the delay results from       
  7744.      unexpected remote server behavior, the local ftp program         
  7745.      must be killed by hand.                                          
  7746.                                                                       
  7747. FILE NAMING CONVENTIONS                                               
  7748.      Files specified as arguments to ftp commands are processed       
  7749.      according to the following rules.                                
  7750.                                                                       
  7751.      1.   If the file name is -, the standard input (for reading)     
  7752.           or the standard output (for writing) is used.               
  7753.                                                                        
  7754.      2.   If the first character of the file name is a bar |, the      
  7755.           remainder of the argument is interpreted as a shell          
  7756.           command.  ftp then forks a shell, using popen(3S) with       
  7757.           the argument supplied, and reads (writes) from the           
  7758.           stdout (stdin).  If the shell command includes spaces,       
  7759.           the argument must be quoted; for example, "| ls -lt". A
  7760.           particularly useful example of this mechanism is            
  7761.           "dir | more".                                               
  7762.                                                                       
  7763.      3.   Failing the above checks, if globbing is enabled, local     
  7764.           file names are expanded according to the rules used in      
  7765.           the csh(1); see the glob command.  If the ftp command       
  7766.           expects a single local file (e.g., put), only the first     
  7767.           filename generated by the globbing operation is used.       
  7768.                                                                       
  7769.      4.   For mget commands and get commands with unspecified         
  7770.           local file names, the local filename is the remote          
  7771.           filename, which may be altered by a case, ntrans, or        
  7772.           nmap setting.  The resulting filename may then be           
  7773.           altered if runique is on.                                   
  7774.                                                                       
  7775.      5.   For mput commands and put commands with unspecified         
  7776.           remote file names, the remote filename is the local         
  7777.           filename, which may be altered by a ntrans or nmap          
  7778.           setting.  The resulting filename may then be altered by     
  7779.           the remote server if sunique is on.                         
  7780.                                                                       
  7781. FILE TRANSFER PARAMETERS                                              
  7782.      The FTP specification identifies many parameters that can        
  7783.      affect a file transfer. The type can be one of ascii, image      
  7784.      (binary), ebcdic, and local byte size (for PDP-10's and          
  7785.      PDP-20's mostly).  ftp supports the ascii and image types of     
  7786.      file transfer, plus local byte size 8 for tenex mode             
  7787.      transfers.                                                       
  7788.                                                                       
  7789.      ftp supports only the default values for the remaining file      
  7790.      transfer parameters:  mode, form, and struct.                    
  7791.                                                                       
  7792. OPTIONS                                                                
  7793.      Options can be specified at the command line, or to the           
  7794.      command interpreter.                                              
  7795.                                                                        
  7796.      The -v (verbose on) option forces ftp to show all responses       
  7797.      from the remote server, as well as report on data transfer        
  7798.      statistics.                                                       
  7799.                                                                        
  7800.      The -n option restrains ftp from attempting "auto-login"          
  7801.      upon initial connection.  If auto-login is enabled, ftp           
  7802.      checks the netrc file in the user's home directory for an         
  7803.      entry describing an account on the remote machine. If no          
  7804.      entry exists, ftp will prompt for the remote machine login        
  7805.      name (default is the user identity on the local machine),         
  7806.      and, if necessary, prompt for a password and an account with      
  7807.      which to login.                                                   
  7808.                                                                       
  7809.      The -i option turns off interactive prompting during             
  7810.      multiple file transfers.                                         
  7811.                                                                       
  7812.      The -d option enables debugging.                                 
  7813.                                                                       
  7814.      The -g option disables file name globbing.                       
  7815.                                                                       
  7816. THE .netrc FILE                                                       
  7817.      The .netrc file contains login and initialization                
  7818.      information used by the "auto-login" process.  It resides in     
  7819.      the user's home directory.  The following tokens are             
  7820.      recognized; they may be separated by spaces, tabs, or new-       
  7821.      lines:                                                           
  7822.                                                                       
  7823.      machine name                                                     
  7824.           Identify a remote machine name.  The auto-login process     
  7825.           searches the .netrc file for a machine token that           
  7826.           matches the remote machine specified on the ftp command     
  7827.           line or as an open command argument.  Once a match is       
  7828.           made, the subsequent .netrc tokens are processed,           
  7829.           stopping when the end of file is reached or another         
  7830.           machine token is encountered.                               
  7831.                                                                       
  7832.      login name                                                       
  7833.           Identify a user on the remote machine.  If this token       
  7834.           is present, the "auto-login" process will initiate a
  7835.           login using the specified name.                             
  7836.                                                                       
  7837.      password string                                                  
  7838.           Supply a password.  If this token is present, the           
  7839.           "auto-login" process will supply the specified string       
  7840.           if the remote server requires a password as part of the     
  7841.           login process.  Note that if this token is present in       
  7842.           the .netrc file, ftp will abort the "auto-login"            
  7843.           process if the .netrc is readable by anyone besides the     
  7844.           user.                                                       
  7845.                                                                       
  7846.      account string                                                   
  7847.           Supply an additional account password.  If this token       
  7848.           is present, the "auto-login" process will supply the        
  7849.           specified string if the remote server requires an           
  7850.           additional account password, or the "auto-login"            
  7851.           process will initiate an ACCT command if it does not.       
  7852.                                                                       
  7853.      macdef name                                                      
  7854.           Define a macro.  This token functions like the ftp          
  7855.           macdef command functions.  A macro is defined with the      
  7856.           specified name; its contents begin with the next .netrc     
  7857.           line and continue until a null line (consecutive new-       
  7858.           line characters) is encountered.  If a macro named init     
  7859.           is defined, it is automatically executed as the last        
  7860.           step in the "auto-login" process.                           
  7861.                                                                       
  7862. SEE ALSO                                                              
  7863.      csh(1).                                                          
  7864.      ftpd(1M) in the UMAX V Administrator's Reference Manual.         
  7865.                                                                       
  7866. BUGS                                                                  
  7867.      Correct execution of many commands depends upon proper           
  7868.      behavior by the remote server.                                   
  7869.                                                                       
  7870.      An error in the treatment of carriage returns in the 4.2BSD      
  7871.      UNIX ASCII-mode transfer code has been corrected.  This          
  7872.      correction may result in incorrect transfers of binary files     
  7873.      to and from 4.2BSD servers using the ascii type.  Avoid this     
  7874.      problem by using the binary image type.
  7875.                           
  7876.                                NOTES
  7877. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  7878.                                NOTES
  7879. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  7880. APPENDIX E - cc
  7881.  
  7882. $man cc                                                                  
  7883.                                                                        
  7884. NAME                                                                   
  7885.      cc - C compiler                                                   
  7886.                                                                        
  7887. SYNOPSIS                                                               
  7888.      cc [ option ] ... file ...                                        
  7889.                                                                        
  7890. DESCRIPTION                                                            
  7891.      The cc command invokes the C language compiler. This C            
  7892.      compiler is an advanced, optimizing compiler that accepts a
  7893.      complete implementation of the C programming language.  For       
  7894.      a more complete description of the compiler, see "C               
  7895.      Language" and "Compiler and C Language" in the UMAX V             
  7896.      Programmer's Guide.                                               
  7897.                                                                        
  7898.      Files with a .c suffix are taken to be C language source          
  7899.      programs.  The compiler processes every C language source         
  7900.      file to produce a corresponding object file with the same         
  7901.      file name and a .o suffix.  Files with a .s suffix are taken      
  7902.      to be assembly language source programs.  These are               
  7903.      assembled to produce a corresponding object file with the         
  7904.      same file name and a .o suffix.  Files with a suffix other        
  7905.      than .c and .s are assumed to be object files (usually            
  7906.      produced by an earlier compilation or assembly) or C-             
  7907.      compatible libraries.  These files, together with any object      
  7908.      code produced by the compiler, are linked in the order they       
  7909.      were specified to produce an executable program file named        
  7910.      a.out.                                                            
  7911.                                                                        
  7912.      If only one input file with a .c or .s suffix is supplied,        
  7913.      the compiler automatically deletes the object file output         
  7914.      produced from that input file after the executable program        
  7915.      file a.out is created.                                            
  7916.                                                                        
  7917.      The cc options that modify the behavior described above are:      
  7918.                                                                        
  7919.      -A       Cause ASCII assembler output to be generated and         
  7920.               automatically piped to the assembler.  The default       
  7921.               is for direct generation of object code. The -A          
  7922.               option is the same as the -q nodirect_code option.       
  7923.                                                                        
  7924.      -Bpath   Run the compiler program contained in pathccom.  If      
  7925.               -B is specified with no path, then the default path      
  7926.               is assumed to be /lib/o and the compiler program in      
  7927.               /lib/occom is run.  If no -B option is specified,        
  7928.               then the compiler program in /lib/ccom is run.           
  7929.                                                                        
  7930.      -c       Compile only. Produce object file output, even if        
  7931.               there was only one source file.                          
  7932.                                                                        
  7933.      -C       Retain comments during the macro preprocessor pass.      
  7934.                                                                        
  7935.      -Dname=def                                                        
  7936.               Define symbol name to be string def, as if by a
  7937.                  #define statement.  If =def is omitted, define name     
  7938.               to be 1.                                                 
  7939.                                                                        
  7940.      -E       Run only the macro preprocessor, process only input      
  7941.               files with the .c suffix; send the result of this        
  7942.               pass to the standard output.                             
  7943.                                                                        
  7944.      -g       Generate special symbol table data for sdb(1) or         
  7945.               cdb(1) and pass the -g flag to the link editor.          
  7946.                                                                        
  7947.      -G       Cause object code to be directly generated by the        
  7948.               compiler, bypassing the intermediate steps of            
  7949.               producing assembly code and assembling it to             
  7950.               produce object code.  This is the default.  The -G       
  7951.               option is the same as the -q direct_code option.         
  7952.                                                                        
  7953.      -Idir    dir is a directory name.  Search for #include files      
  7954.               whose names do not begin with / first in the             
  7955.               directory containing the source file, then in dir,       
  7956.               and then in a list of standard defaults.  Multiple       
  7957.               -I options can establish a hierarchy of #include         
  7958.               file directories.                                        
  7959.                                                                        
  7960.      -o output                                                         
  7961.               Name the final, executable output file output            
  7962.               instead of a.out.  Note the space between the -o         
  7963.               and the file name.                                       
  7964.                                                                        
  7965.      -O       Perform optimizations which speed up the generated       
  7966.               code. Also, perform any space optimizations which        
  7967.               do not impact code speed.  See also the -q option.       
  7968.                                                                        
  7969.      -p       Prepare to generate an execution profile using           
  7970.               prof(1).  Include special profiling code that            
  7971.               counts how many times each routine is called.  If        
  7972.               linking occurs, use a special startup routine that       
  7973.               calls monitor(3C) and produces a mon.out file upon       
  7974.               termination.  Uses special profiling versions of         
  7975.               standard libraries found in /usr/lib/libp/lib*.a.        
  7976.              NOTE: use of the MARK macro (see prof(5)) requires        
  7977.               the -A option of cc.                                     
  7978.                                                                        
  7979.      -pg      Prepare to generate an execution profile using           
  7980.               gprof(1).  Include special profiling code that           
  7981.               counts how many times each function is called and        
  7982.               how much time is spent in each.  If linking occurs,      
  7983.               use a special startup function that calls                
  7984.               monstartup and produces a gmon.out file upon             
  7985.               termination.  Uses special profiling versions of         
  7986.               standard libraries found in /usr/lib/libp/lib*.a.        
  7987.               Note: Use of the MARK macro (see prof(5)) requires       
  7988.               the -A option of cc.                                     
  7989.                                                                        
  7990.      -P       Run all .c files through the preprocessing step,         
  7991.               putting the result in the corresponding output file      
  7992.               with a .i suffix.                                        
  7993.                                                                        
  7994.      -R       Make initialized variables shared and read-only (by      
  7995.               passing the -r option to the assembler).                 
  7996.                                                                        
  7997.      -S       Generate only assembly language output, putting it       
  7998.               in one or more files that have the source file name      
  7999.               and an .s suffix.                                       
  8000.                                                                       
  8001.      -Uname   Undefine symbol name to remove its default              
  8002.               definition.                                             
  8003.                                                                       
  8004.      -v       Report the names of all subprocesses invoked in the     
  8005.               compiled program, and their arguments.  This option     
  8006.               shows any files that are linked automatically and       
  8007.               the current compiler, assembler, and link editor        
  8008.               options.                                                
  8009.                                                                       
  8010.      -w       Suppress warning diagnostics.                           
  8011.                                                                       
  8012.      -Wc,arg                                                          
  8013.      -Wa,arg                                                          
  8014.      -Wl,arg  Pass option arg to the compiler (see "C Compiler        
  8015.               Internal Options" in the "Compiler and C Language"      
  8016.               chapter in the UMAX V Programmer's Guide),              
  8017.               assembler (see as(1)), or linker (see ld(1)),           
  8018.               respectively.                                           
  8019.                                                                       
  8020.      The following options are intended to provide more detailed      
  8021.      control over the generated code and action of the compiler.      
  8022.      In general, they should only be used for special situations.     
  8023.                                                                       
  8024.      -q qualifier                                                     
  8025.      -q qualifier=arg                                                 
  8026.               Modify the generated code of the compiler to            
  8027.               reflect various special requirements of a program.      
  8028.               Qualifiers include the following:                       
  8029.                                                                       
  8030.               align_text, noalign_text                                
  8031.                   Enable alignment of text segments on boundaries     
  8032.                   that allows the burst mode of systems equipped      
  8033.                   with APCs (Advanced Dual Processor Cards,           
  8034.                   utilizing the NS32332 CPU chip) to be most          
  8035.                   effectively used.  The default option is            
  8036.                   -q noalign_text, unless the -q optimize=time        
  8037.                   option is specified.                                
  8038.                                                                       
  8039.               xpc, apc, dpc                                           
  8040.                   Generate code optimized for a system equipped       
  8041.                   with XPCs (Extended Performance Dual Processor      
  8042.                   Cards, utilizing the NS32532 CPU chip), APCs        
  8043.                   (Advanced Dual Processor Cards, utilizing the       
  8044.                   NS32332 CPU chip), or DPCs (Dual Processor          
  8045.                   Cards, utilizing the NS32032 CPU chip).  If the     
  8046.                   -q xpc option is specified, then the                
  8047.                   preprocessor symbol ns32532 is defined and code     
  8048.                   optimal for the NS32532 is generated.  If the       
  8049.                   -q apc option is specified, then the                
  8050.                   preprocessor symbol ns32332 is defined and the      
  8051.                   -q align_text option is enabled.  If the -q dpc     
  8052.                   option is specified, then the preprocessor          
  8053.                   symbol ns32032 is defined and the                   
  8054.                   -q noalign_text option is enabled.  If neither      
  8055.                   -q xpc nor -q apc nor -q dpc is specified, then     
  8056.                   the default option is either -q xpc or -q apc       
  8057.                   or -q dpc , depending upon whether the system       
  8058.                   upon which the compiler is running is equipped      
  8059.                   with XPCs, APCs, or DPCs, respectively.  Code       
  8060.                   generated with these options will work on all       
  8061.                   XPCs, APCs, and DPCs.                               
  8062.                                                                       
  8063.               asmdir=prefix                                           
  8064.               crt0dir=prefix                                          
  8065.               lddir=prefix                                            
  8066.                   Overrides the defaults for the locations of         
  8067.                   as(1) (the assembler), the relevant startup         
  8068.                   routine (either crt0.o, mcrt0.o, or gcrt0.o),       
  8069.                   and ld(1) (the link editor).  The default           
  8070.                   values for these are asmdir=/bin/,                  
  8071.                   crt0dir=/lib/ (if the startup routine is crt0.o     
  8072.                   or mcrt0.o), crt0dir=/usr/lib/ (if the startup      
  8073.                   routine is gcrt0.o), and lddir=/bin/.               
  8074.                                                                       
  8075.               compiler_registers, nocompiler_registers                
  8076.                   Enable or disable compiler allocation of local      
  8077.                   variables to registers beyond those specified       
  8078.                   by register storage class specifications. The       
  8079.                   default option is -q compiler_registers.  The       
  8080.                   -q nocompiler_registers option should only be       
  8081.                   used when code is written to depend on the          
  8082.                   existence of non-register class variables in        
  8083.                   memory.                                             
  8084.                                                                       
  8085.               direct_code, nodirect_code                              
  8086.                   Enable or disable the direct generation of code     
  8087.                   by the compiler. When enabled, the compiler         
  8088.                   will directly generate object code, bypassing       
  8089.                   the intermediate steps of producing assembly        
  8090.                   code and assembling it to produce the object        
  8091.                   code. The -q nodirect_code option (same as the      
  8092.                   -A option) should only be needed if the source      
  8093.                   file contains asm statements. The                   
  8094.                   -q direct_code option (same as the -G option)       
  8095.                   is enabled by default. The -q nodirect_code         
  8096.                   option is enabled if the -R option is               
  8097.                   specified.                                          
  8098.                                                                       
  8099.               enter_exits, noenter_exits                              
  8100.                   Generate enter and exit instructions at             
  8101.                   subroutine start and end.  Enter and exit           
  8102.                   instructions make stack tracing by debuggers        
  8103.                   possible.  The -q noenter_exits option is           
  8104.                   enabled by default, unless the -g option is         
  8105.                   used.                                               
  8106.                                                                       
  8107.               extensions, noextensions                                
  8108.               extensions=parallel                                     
  8109.               extensions=microtasking                                 
  8110.                   Specifies which language extensions will be         
  8111.                   recognized.  The -q extensions=parallel option      
  8112.                   specifies that extensions which support             
  8113.                   parallel programming are recognized.  This          
  8114.                   includes shared memory declarations and in-line     
  8115.                   code generation for spin lock routines.             
  8116.                   Consult the section "C Parallel Programming         
  8117.                   Extensions" in Chapter 18, Compiler and C           
  8118.                   Language in the UMAX V Programmer's Guide.  The      
  8119.                   -q extension=microtasking option specifies that      
  8120.                   extensions which support microtasking are            
  8121.                   recognized.  This includes the                       
  8122.                   -q extension=parallel extensions, and also           
  8123.                   specifies that the microtasking library and an       
  8124.                   alternate version of crt0.o are to be used by        
  8125.                   the load step.  The -q extensions option is          
  8126.                   equivalent to -q extension=microtasking.  The        
  8127.                   default option is -q noextensions.                   
  8128.                                                                        
  8129.               limitfregs, nolimitfregs                                 
  8130.                   Use or don't use the new NS32532 double              
  8131.                   precision floating point registers f1, f3, f5,       
  8132.                   f7. This flag is valid only in conjunction with      
  8133.                   the -q xpc flag. The default value for this          
  8134.                   flag is -q limitfregs (the new registers are         
  8135.                   not used). The double precision registers f1,        
  8136.                   f3, f5, f7 do not exist on APCs and DPCs, and        
  8137.                   code that uses these registers will not work on      
  8138.                   APCs and DPCs.                                       
  8139.                                                                        
  8140.               includes, noincludes                                     
  8141.                   Look or don't look for C language include files      
  8142.                   in the standard directory /usr/include.              
  8143.                   -q noincludes specifies there is no standard         
  8144.                   location for the include files.  The default         
  8145.                   value is -q includes.                                
  8146.                                                                        
  8147.               long_case, nolong_case                                   
  8148.                   Enable or disable the generation of case             
  8149.                   statements using a full four byte displacement.      
  8150.                   The -q nolong_case option is the default,            
  8151.                   allowing case statements to span 8 Kilobytes.        
  8152.                   The -q long_case option allows case statements       
  8153.                   to span 16 Megabytes. This should only be            
  8154.                   needed in unusual circumstances.                     
  8155.                                                                        
  8156.               long_jump, nolong_jump                                   
  8157.                   Enable or disable the generation of jumps with       
  8158.                   four byte displacements when the assembler is        
  8159.                   unable to resolve them in 1 byte.  This option       
  8160.                   only has effect when direct code generation is       
  8161.                   not enabled.  The default option,                    
  8162.                   -q nolong_jump, allows branches to span up to        
  8163.                   _8 Kilobytes.  The -q long_jump option will          
  8164.                   allow branches to span up to _16 Megabytes.          
  8165.                                                                        
  8166.               loops, noloops                                           
  8167.                   Enable or disable loop optimizations. These          
  8168.                   optimizations include loop-invariant hoisting        
  8169.                   and strength reduction. The default option is        
  8170.                   -q noloops.                                          
  8171.                                                                        
  8172.               optimize, nooptimize                                     
  8173.       optimize=none,optimize=standard,optimize=time,optimize=space     
  8174.                   Specify the level of optimization.  The              
  8175.                   -q optimize option is equivalent to the              
  8176.                   -q optimize=standard.  The -q nooptimize option      
  8177.                   is equivalent to -q optimize=none.  The -O           
  8178.                   option is equivalent to -q optimize=standard.        
  8179.                   The -q optimize=standard option enables a set        
  8180.                   of optimizations that do not take an excessive       
  8181.                   time to generate and do not overly favor space       
  8182.                   over time or vice versa.  The -q optimize=time       
  8183.                   option enables optimizations which may take          
  8184.                   longer to recognize but should yield a program       
  8185.                   that takes minimal time.  This option enables        
  8186.                   -q align_text, -q loops, and -q novolatile. If       
  8187.                   any of these options are inappropriate, they         
  8188.                   may be overridden by the appropriate -q noxxx        
  8189.                   option.  The -q optimize=space option enables        
  8190.                   optimizations which may take longer to generate      
  8191.                   but should yield a program which takes minimal       
  8192.                   space.  This option enables                          
  8193.                   -q preload_constants and -q tail_merge.  The         
  8194.                   default option is -q optimize=none.                  
  8195.                                                                        
  8196.               preload_constants, nopreload_constants                   
  8197.                   Enable or disable the linking of constant            
  8198.                   values and addresses that are frequently             
  8199.                   referenced in the source code at the start of a
  8200.                   program.  This option saves space; it may save       
  8201.                   execution time if the constants and addresses        
  8202.                   are also referenced frequently during                
  8203.                   execution. The -q nopreload_constants option is      
  8204.                   the default; the -q preload_constants option is     
  8205.                   enabled by the -O option.                           
  8206.                                                                       
  8207.               reg_params, noreg_params                                
  8208.                   Pass the first two parameters to a subroutine       
  8209.                   in registers rather than on the stack.  The         
  8210.                   -q noreg_params option is the default.  The         
  8211.                   standard libraries provided with the system         
  8212.                   assume -q noreg_params and will not work with       
  8213.                   object files built with the -q reg_params           
  8214.                   option.                                             
  8215.                                                                       
  8216.               sbfixed, nosbfixed                                      
  8217.                   Enable or disable the use of the NS32000 sb         
  8218.                   register when generating immediate addresses.       
  8219.                   The -q sbfixed option is the default.               
  8220.                                                                       
  8221.               signed_bit_fields, nosigned_bit_fields                  
  8222.                   Enable or disable making bit fields in              
  8223.                   structures of type int, short, and char to be       
  8224.                   signed. The default option,                         
  8225.                   -q nosigned_bit_fields, is to make all fields       
  8226.                   unsigned.                                           
  8227.                                                                       
  8228.               small_enums, nosmall_enums                              
  8229.                   Enable or disable the allocation of each enum       
  8230.                   type as the smallest predefined type that can       
  8231.                   represent all of the values that are listed         
  8232.                   (that is values of type char, short, int,           
  8233.                   unsigned char, unsigned short, or unsigned that     
  8234.                   are used in the enum statement). The default        
  8235.                   option, -q nosmall_enums, allocates an enum         
  8236.                   type as an int.                                     
  8237.                                                                       
  8238.               standard_library, nostandard_library                    
  8239.                   Allows the compiler to replace calls to             
  8240.                   standard libc routines with equivalent in-line      
  8241.                   code.  The default option is                        
  8242.                   -q nostandard_library, unless the                   
  8243.                   -q optimize=time option is specified.               
  8244.                                                                       
  8245.               tail_merge, notail_merge                                
  8246.                   Enable or disable branch-tail merging, an           
  8247.                   optimization which reduces code size by sharing     
  8248.                   common portions of then and else clauses or of      
  8249.                   case switches.   The -q tail_merge option is        
  8250.                   enabled by default, and disabled when -O is         
  8251.                   specified.                                          
  8252.                                                                       
  8253.               volatile, novolatile                                    
  8254.                   Disable or enable additional optimization on        
  8255.                   the assumption that memory never changes except     
  8256.                   as the result of explicit store operations. The     
  8257.                   default option, -q volatile, disables these         
  8258.                   optimizations.  The -q novolatile option should     
  8259.                   be used when all variables that can be modified     
  8260.                   asynchronously (e.g., by signal handlers) have      
  8261.                   type volatile.  Asynchronous modification could     
  8262.                   happen, for example, with signals, device           
  8263.                   drivers, and parallel processes accessing           
  8264.                   shared memory.  The current default is              
  8265.                   -q novolatile.  In the future, the goal is to       
  8266.                   have -q volatile the default value.                 
  8267.                                                                       
  8268. FILES                                                                 
  8269.      file.c              input file                                   
  8270.      file.o              object file                                  
  8271.      a.out               linked output                                
  8272.      /lib/ccom           compiler                                     
  8273.      /lib/occom          backup compiler                              
  8274.      /lib/crt0.o         runtime startoff                             
  8275.      /lib/mcrt0.o        startoff for profiling                       
  8276.      /lib/libc.a         standard library, see intro(3)                
  8277.      /usr/libp/lib*.a    profiling libraries, see intro(3)             
  8278.      /usr/include        standard directory for #include files         
  8279.      mon.out             file produced for analysis by prof(1)         
  8280.                                                                        
  8281. SEE ALSO                                                               
  8282.      adb(1), as(1), cdb(1), gprof(1), ld(1), prof(1), sdb(1),          
  8283.      a.out(4), monitor(3C).                                            
  8284.      cflow(1) in the UMAX V User's Reference Manual.                   
  8285.      "C Language" and "Compiler and C Language" in the UMAX V          
  8286.      cflow(1) in the UMAX V User's Reference Manual.                   
  8287.      "C Language" and "Compiler and C Language" in the UMAX V         
  8288.      Programmer's Guide.                                              
  8289.      B. W. Kernighan and D. M. Ritchie, The C Programming             
  8290.      Language.  Prentice-Hall, 1978.                                  
  8291.                                                                       
  8292. DIAGNOSTICS                                                           
  8293.      The diagnostics produced by C itself are intended to be          
  8294.      self-explanatory.  Occasional messages may be produced by        
  8295.      the assembler or link editor.                                    
  8296.                                NOTES
  8297. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  8298.                                NOTES
  8299. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  8300. APPENDIX F - f77
  8301.  
  8302. $man f77                                                                  
  8303.                                                                        
  8304. NAME                                                                   
  8305.      f77 - Fortran-77 compiler                                         
  8306.                                                                        
  8307. SYNOPSIS                                                               
  8308.      f77 [ options ] file [ options ] [ files ] ...                    
  8309.                                                                        
  8310. DESCRIPTION                                                            
  8311.      The f77 compiler is an advanced, optimizing Fortran-77            
  8312.      compiler that accepts a complete implementation of the            
  8313.      standard Fortran language defined by ANSI standard X3.9-          
  8314.      1978.  It also has extensions to support VAX Fortran              
  8315.      functionality and parallel programming.  The  Fortran-77          
  8316.      compiler accepts any or none of the options described             
  8317.      following, and one or more input file names.  Files and           
  8318.      options can be mixed in any order.  Any differences between       
  8319.      4.2 and  V are noted in the text.                                 
  8320.                                                                        
  8321.      Files that have an f or F extension are taken to be               
  8322.      Fortran-77 language source programs.  The compiler processes      
  8323.      every Fortran-77 source file to produce a corresponding           
  8324.      object file with the same file name and an o extension.           
  8325.      Source files that have an F extension are passed through the      
  8326.      C language macro preprocessor before being compiled by the        
  8327.      f77 compiler.  Files that have an e extension are assumed to      
  8328.      be EFL (Extended Fortran Language) files, which are passed        
  8329.      through the efl preprocessor before being compiled by the         
  8330.      Fortran-77 compiler.  Files that have an r extension are          
  8331.      taken to be Ratfor files and passed through the ratfor            
  8332.      preprocessor before being compiled.  Files that have an s         
  8333.      extension are assumed to be assembly language source              
  8334.      programs.  These are assembled to produce a corresponding         
  8335.      object file with the same file name and an o extension.           
  8336.                                                                        
  8337.      Files with extensions other than f, F, e, r, and s are            
  8338.      assumed to be Fortran-compatible libraries, or object files       
  8339.      such as those files produced by an earlier compilation or         
  8340.      assembly.  These files, together with any object code             
  8341.      produced during the compilation, are loaded to produce an         
  8342.      executable program file named aout.                               
  8343.                                                                        
  8344.      If only one input file with an f, F, e, r, or s extension is      
  8345.      supplied, the compiler automatically deletes the object file      
  8346.      output produced from that input file after executable             
  8347.      program file aout has been created.                               
  8348.                                                                        
  8349.      All unrecognized options and all file names with extensions     
  8350.      other than .f, .F, .e, .r, .c are passed to the loader.  For    
  8351.      assembler options, see as(1); for loader options, see ld(1).    
  8352.      The f77 options are:                                            
  8353.                                                                      
  8354.      -Bprefix  Run the compiler program contained in file            
  8355.                prefixfcom.  If prefix is not given,                  
  8356.                /usr/lib/ofcom is the default compiler used.            
  8357.                                                                        
  8358.      -c        Compile only.  Produce object file output (even if      
  8359.                there was only one source file) and do not load         
  8360.                the program after compiling it.                         
  8361.                                                                        
  8362.      -Dname=def                                                        
  8363.                Define symbol name to be string def, when running       
  8364.                the C language preprocessor, as if by a #define         
  8365.                statement.  If =def is omitted, defines name to be      
  8366.                1 while running the C preprocessor.                     
  8367.                                                                        
  8368.      -Estring  Pass option(s) string to the efl preprocessor when      
  8369.                processing input files that have the e extension.       
  8370.                                                                        
  8371.      -F        Generate only Fortran language output from the          
  8372.                ratfor or efl preprocessor, placing it in a file        
  8373.                that has the source file name and the f extension,      
  8374.                but do not run the Fortran-77 compiler.                 
  8375.                                                                        
  8376.      -g        Generate special symbol table data for the sdb(1)       
  8377.                debugger (or the optional debugger), and pass the       
  8378.                -lg flag to the loader.                                 
  8379.                                                                        
  8380.      -Ipath    Include source files from the directory named path      
  8381.                when running the C language preprocessor.  When         
  8382.                compiling source files named with the F extension,      
  8383.                search for #include files (whose names do not           
  8384.                begin with /) first in the directory containing         
  8385.                the source file, then in the directory path, and        
  8386.                then in a list of standard defaults.  Multiple -I       
  8387.                options can establish a hierarchy of #include file      
  8388.                directories.                                            
  8389.                                                                        
  8390.      -i2       Make the default length of integer constants and        
  8391.                variables, and all logical quantities, be short.        
  8392.                Complementary option -i4 is the default, which          
  8393.                calls for long integer variables and constants.         
  8394.                                                                        
  8395.      -m        Apply the M4 macro preprocessor to each EFL or          
  8396.                Ratfor source file before passing it through the        
  8397.                efl or ratfor preprocessor.                             
  8398.                                                                        
  8399.      -O        Perform optimizations that speed up the generated       
  8400.                code; also perform any space optimizations that do      
  8401.                not impact code speed.  See also the -q qualifier       
  8402.                options.                                                
  8403.                                                                        
  8404.      -o output Name the final, executable output file output           
  8405.                rather than aout.                                       
  8406.                                                                        
  8407.      -onetrip  Generate object code that executes the range of         
  8408.                every do loop at least once, even if the initial        
  8409.                value of the loop index exceeds the limit value.        
  8410.                                                                        
  8411.      -p        Prepare to generate an execution profile using          
  8412.                prof(1).  Include special profiling code that           
  8413.                counts how many times each routine is called.  If       
  8414.                loading occurs, use a special startup routine that      
  8415.                calls monitor(3) and produces a monout file upon        
  8416.                termination.  Use a special profiling library           
  8417.                instead of the standard C library.                      
  8418.                                                                        
  8419.      -pg       Generate an execution profile using gprof.              
  8420.                Include special profiling code that counts how          
  8421.                many times each routine is called.  If loading          
  8422.                occurs, use a special startup routine that calls        
  8423.                monitor(3) and produces one or more gmon.pid upon       
  8424.                termination.  A profiling version of the standard      
  8425.                library is used.                                       
  8426.                                                                       
  8427.      -R        Make initialized variables shared and read-only        
  8428.                (by passing the -r option to the assembler).           
  8429.                                                                       
  8430.      -Rstring  Pass option(s) string to the ratfor preprocessor       
  8431.                when processing input files that have an r             
  8432.                extension.                                             
  8433.                                                                       
  8434.      -S        Generate assembly language output for each source      
  8435.                file, but do not assemble it.  Assembler output        
  8436.                for a source file with the extension f, F, e, r,       
  8437.                or c is put in a file with the same name and a s       
  8438.                extension.                                             
  8439.                                                                       
  8440.      -U        Do not convert uppercase letters to lowercase          
  8441.                letters.  By default Fortran programs are              
  8442.                converted to lowercase letters except within           
  8443.                character string constants.                            
  8444.                                                                       
  8445.      -u        Disable automatic data typing and, instead, make       
  8446.                the default type of a variable the undefined type.     
  8447.                                                                       
  8448.      -v        Report the names of all subprocesses invoked by        
  8449.                the compiler and their arguments.                      
  8450.                                                                       
  8451.      -w        Suppress warning diagnostics.                          
  8452.                                                                       
  8453.      -w66      Recognized only for compatibility with the             
  8454.                Portable Fortran-77 Compiler, which used this          
  8455.                option to suppress warnings about Fortran-66           
  8456.                features encountered during compilation.  The          
  8457.                Fortran-77 compiler does not flag language             
  8458.                elements that are unique to Fortran-66.                
  8459.                                                                       
  8460.      -W[a c l], arg                                                   
  8461.                Pass option arg to the assembler, compiler, or         
  8462.                linker, as specified respectively by -Wa, arg,         
  8463.                -Wc, arg, or -Wl, arg.  The internal options for       
  8464.                the  f77 compiler include implementation options       
  8465.                used to reconfigure the compiler for alien             
  8466.                operating environments, and debugging options used     
  8467.                for testing compiler software.  These options          
  8468.                should never be used in normal operation; they are     
  8469.                described in the Fortran-77 Manual.                    
  8470.                                                                       
  8471.      -q qualifier[=arg]                                               
  8472.                The qualifier options provide more detailed            
  8473.                control over the generated code and action of the      
  8474.                compiler.  They modify the generated code of the       
  8475.                compiler to reflect various special requirements       
  8476.                of a program, and in general should only be used       
  8477.                for special situations.  The qualifier options         
  8478.                deal with architecture, optimization selections,       
  8479.                file configuration, and Fortran language               
  8480.                extensions.  In this listing they are grouped by       
  8481.                category.  Both the qualifiers and any arguments,      
  8482.                which have compiler-defined values, can be             
  8483.                abbreviated to their minimum number of unique          
  8484.                characters.  The qualifiers are:                       
  8485.                                                                       
  8486.                     portable                                          
  8487.                apc, apc01, apc02, dpc, xpc[,2arg], host_is_target,    
  8488.                      These qualifiers select generation of code       
  8489.                      that is compatible with Multimax systems         
  8490.                      having APC DPC or XPC (National                  
  8491.                      Semiconductor NS32xxx-based) processor           
  8492.                      boards.  The default is to generate code         
  8493.                      appropriate for the machine on which the         
  8494.                      compiler is running.  (Differences between       
  8495.                      generated APC and DPC code are primarily in      
  8496.                      alignment optimization.)                         
  8497.                                                                       
  8498.                      apc   The apc qualifier selects APC01 code       
  8499.                            and the libm_apc.a math library.           
  8500.                                                                       
  8501.                      apc01 The apc01 qualifier is the same as the     
  8502.                            apc qualifier.  It is equivalent to        
  8503.                            the obsoleted switch combination,          
  8504.                            -q apc -q nofpa.                           
  8505.                                                                       
  8506.                      apc02 The apc02 qualifier selects APC02 code     
  8507.                            (with Cone instructions) and uses the      
  8508.                            libm_fpa.a math library.  This is          
  8509.                            equivalent to the obsoleted switch         
  8510.                            combination, -q apc -q fpa.                  
  8511.                                                                        
  8512.                      dpc   The dpc qualifier selects code              
  8513.                            optimized for a DPC system, and uses        
  8514.                            the libm_apc.a library.                     
  8515.                                                                        
  8516.                      xpc[,arg]                                         
  8517.                            The xpc qualifier generates code            
  8518.                            optimized for XPC systems, using the        
  8519.                            libm_xpc.a math library.  Since xpc         
  8520.                            permits access of 4 additional              
  8521.                            floating point (fp) registers and uses      
  8522.                            floating point instructions that do         
  8523.                            not exist for APC and DPC boards, code      
  8524.                            compiled using this option may not be       
  8525.                            portable to APC and DPC systems.  xpc       
  8526.                            accepts the arguments limitfregs and        
  8527.                            nolimitfregs.  -q xpc,limitfregs            
  8528.                            assures code compatibility with APC         
  8529.                            and DPC systems, selecting the              
  8530.                            libm_apc.a math library rather than         
  8531.                            libm_xpc.a and suppressing the usage        
  8532.                            of some double-precision floating           
  8533.                            point registers that are available to       
  8534.                            XPC systems; only 4 double-precision        
  8535.                            float registers are used.                   
  8536.                            -q xpc,nolimitfregs permits all             
  8537.                            floating point registers to be used,        
  8538.                            and uses the libm_xpc.a math library.       
  8539.                                                                        
  8540.                      host_is_target                                    
  8541.                            The host_is_target qualifier optimizes      
  8542.                            code for the system performing the          
  8543.                            compilation.  No attempt is made to         
  8544.                            preserve portability.  This is default      
  8545.                            behavior.                                   
  8546.                                                                        
  8547.                      portable                                          
  8548.                            The portable qualifier generates code       
  8549.                            that is portable across all Multimax        
  8550.                            APC, DPC, and XPC systems.  A
  8551.                            universal math library, libm_apc.a, is     
  8552.                            used.  Only optimizations that are         
  8553.                            explicitly portable are used.              
  8554.                            Produced code is portable to APC and       
  8555.                            DPC systems even if compiled on an XPC     
  8556.                            system, since only 4 double-precision      
  8557.                            float registers are used.                  
  8558.                                                                       
  8559.                align_text, noalign_text                               
  8560.                      Enable or disable alignment of text segments     
  8561.                      on boundaries to optimize burst mode on          
  8562.                      Multimax systems having APC s.  The default      
  8563.                      is noalign_text, unless optimize=time is         
  8564.                      enabled.                                         
  8565.                                                                       
  8566.                asmdir=prefix                                          
  8567.                      Use the assembler located in the prefixas        
  8568.                      file instead of the default assembler,           
  8569.                      /bin/as.                                         
  8570.                                                                       
  8571.                compiler_registers, nocompiler_registers               
  8572.                      Enable or disable compiler allocation of         
  8573.                      local variables to registers beyond those        
  8574.                      specified by register storage class              
  8575.                      specifications.  The default is                  
  8576.                      compiler_registers.  nocompiler_registers        
  8577.                      should only be used when code is written to      
  8578.                      depend on the existence of non-register          
  8579.                      class variables in memory.                       
  8580.                                                                       
  8581.                crt0dir=prefix                                         
  8582.                      Use the prefixcrt0.o startup file instead of     
  8583.                      the default startup file, /lib/crt0.o.           
  8584.                                                                       
  8585.                d_lines, nod_lines                                     
  8586.                      Enable or disable the recognition of any         
  8587.                      comment line, beginning with a D, as a code      
  8588.                      line.  The default is nod_lines.                 
  8589.                                                                       
  8590.                direct_code, nodirect_code                             
  8591.                      Enable or disable the direct generation of       
  8592.                      code by the compiler.  When enabled, the         
  8593.                      compiler directly generates object code,         
  8594.                      bypassing the intermediate steps of              
  8595.                      producing assembly code and assembling it to     
  8596.                      produce the object code.  The nodirect_code      
  8597.                      qualifier should only be needed if the           
  8598.                      source file contains asm statements.             
  8599.                      direct_code is enabled by default.               
  8600.                      nodirect_code is enabled if the -R option is     
  8601.                      specified.                                       
  8602.                                                                       
  8603.                extensions[=arg], noextensions                         
  8604.                      Enable or disable the specification of           
  8605.                      Fortran extensions.  The default qualifier       
  8606.                      is noextensions.  The available arguments         
  8607.                      are:                                              
  8608.                                                                        
  8609.                      berkeley_f77   Supports the standard UNIX         
  8610.                                     f77.  This is equivalent to       
  8611.                                     noextensions.                     
  8612.                                                                       
  8613.                      extended_f77   Supports an extension to f77      
  8614.                                     that allows Fortran programs      
  8615.                                     written for VAX/VMS to be         
  8616.                                     compiled on Multimax systems.     
  8617.                                     This is the default when the      
  8618.                                     -q extensions qualifier is        
  8619.                                     given without an argument.        
  8620.                                                                       
  8621.                      parallel       Recognizes the extensions         
  8622.                                     that support parallel             
  8623.                                     programming, including shared     
  8624.                                     memory declarations and           
  8625.                                     spinlocks in-line.  This does     
  8626.                                     not change the value of an        
  8627.                                     earlier specified                 
  8628.                                     berkeley_f77 or extended_f77      
  8629.                                     selection.                        
  8630.                                                                       
  8631.                lddir=prefix                                           
  8632.                      Use the link editor in prefixld instead of       
  8633.                      the default, /bin/ld.                            
  8634.                                                                       
  8635.                long_case, nolong_case                                 
  8636.                      Enable or disable the generation of case         
  8637.                      statements using a full four-byte                
  8638.                      displacement.  nolong_case is the default,       
  8639.                      allowing case statements to span 4               
  8640.                      Kilobytes.  long_case allows case statements     
  8641.                      to span 2 Megabytes.  This should only be        
  8642.                      needed in unusual circumstances.                 
  8643.                                                                       
  8644.                long_jump, nolong_jump                                 
  8645.                      Enable or disable the generation of jumps        
  8646.                      with four-byte displacements when the            
  8647.                      assembler is unable to resolve them in one       
  8648.                      byte.  The default, nolong_jump, allows          
  8649.                      branches to span up to _8 Kilobytes.             
  8650.                      long_jump allows branches to span up to _16      
  8651.                      Megabytes.  Direct code generation selects       
  8652.                      one-, two-, or four-byte displacement as         
  8653.                      appropriate, regardless of the setting of        
  8654.                      this option.                                     
  8655.                                                                       
  8656.                loops, noloops                                         
  8657.                      Enable or disable loop optimizations.  These     
  8658.                      optimizations include loop-invariant             
  8659.                      hoisting and strength reduction.  The            
  8660.                      default is noloops.                              
  8661.                                                                       
  8662.                optimize[=arg], nooptimize                             
  8663.                      Enable or disable different levels of            
  8664.                      optimization.  The default is optimize=none.     
  8665.                      The available arguments are:                     
  8666.                                                                       
  8667.                      none       Enable no special optimizations.      
  8668.                                 none is equivalent to nooptimize.     
  8669.                                                                       
  8670.                      space      Enable optimizations which may        
  8671.                                 take longer to generate but which     
  8672.                                 should produce a program that         
  8673.                                 requires minimal space.  This         
  8674.                                 argument also enables                 
  8675.                                 preload_constants and tail_merge.     
  8676.                                                                       
  8677.                      standard   Enable a set of optimizations         
  8678.                                 that do not take an excessive         
  8679.                                 amount of time to generate and        
  8680.                                 which do not favor space over         
  8681.                                 time (or vice versa).                 
  8682.                      time       Enable optimizations which may        
  8683.                                 take longer to recognize but          
  8684.                                 which should produce a program        
  8685.                                 that requires minimal execution       
  8686.                                 time.  This argument also enables     
  8687.                                 align_text, loops, and                
  8688.                                 novolatile.                           
  8689.                                                                       
  8690.                preload_constants, nopreload_constants                 
  8691.                      Enable or disable the loading of constant        
  8692.                      values and addresses that are frequently         
  8693.                      referenced in the source code at the start       
  8694.                      of a program.  This option saves space; it       
  8695.                      may save execution time if the constants and     
  8696.                      addresses are also referenced frequently         
  8697.                      during execution.  no_preload_constants is       
  8698.                      the default; preload_constants is enabled by     
  8699.                      the -O option.                                   
  8700.                                                                       
  8701.                single_lib, nosingle_lib                               
  8702.                      Enable or disable the use of single              
  8703.                      precision math routines for certain built-in     
  8704.                      functions when the functions are called with     
  8705.                      single precision arguments.  The single          
  8706.                      precision versions offer significantly           
  8707.                      increased speed with almost no reduction in      
  8708.                      accuracy.  single_lib is enabled by default.     
  8709.                                                                       
  8710.                tail_merge, notail_merge                               
  8711.                      Enable or disable branch-tail merging, an        
  8712.                      optimization that reduces code size by           
  8713.                      sharing common portions of then and else         
  8714.                      clauses or of case switches.  tail_merge is      
  8715.                      disabled by default.                             
  8716.                                                                       
  8717.                volatile, novolatile                                   
  8718.                      Enable or disable additional optimization on     
  8719.                      the assumption that memory never changes         
  8720.                      except as the result of explicit store           
  8721.                      operations.  The default is volatile, unless     
  8722.                      optimize=time is selected.  novolatile,          
  8723.                      which enables the optimizations, is              
  8724.                      available only when optimize=time is             
  8725.                      selected.  novolatile should only be used        
  8726.                      when it is clear that no variables can be        
  8727.                      modified asynchronously.  Asynchronous           
  8728.                      modification could happen, for example, with     
  8729.                      signals, device drivers, or parallel             
  8730.                      processes accessing shared memory.               
  8731.                                                                       
  8732. RESTRICTIONS                                                          
  8733.      The -q flag and its qualifier options replace the following      
  8734.      options, which are no longer supported:                          
  8735.                                                                       
  8736.      -A  Replaced by -q nodirect_code.                                
  8737.                                                                       
  8738.      -G  Replaced by -q direct_code.                                  
  8739.                                                                       
  8740.      -H  Replaced by -q notail_merge.                                 
  8741.                                                                       
  8742.      -J  Replaced by -q long_jump.                                    
  8743.                                                                       
  8744.      -T  Replaced by -q loops.                                        
  8745.                                                                       
  8746.      -V  Replaced by -q novolatile.                                   
  8747.                                                                       
  8748. FILES                                                                 
  8749.      ./fort[pid].?           temporary fortran process files          
  8750.      a.out                   loaded output file                       
  8751.      file.[fFresc]           input file                               
  8752.      file.o                  object file                              
  8753.   gmon.[pid]              file produced for analysis by monitor(3)    
  8754.      mon.out                 file produced for analysis by prof(1)    
  8755.      /lib/cpp                C preprocessor                           
  8756.      /lib/libc.a             C library                                
  8757.      /lib/cpp                C preprocessor                           
  8758.      /lib/libc.a             C library                                
  8759.      /usr/lib/fcom           Fortran compiler                         
  8760.      /usr/lib/libFBERK.a     combined libF77.a, libI77.a, and         
  8761.                              libU77.a library                         
  8762.      /usr/lib/libFBERK_p.a   profiling combined Berkeley function     
  8763.                              library                                  
  8764.      /usr/lib/libFORT.a      combined libFBERK.a and libX77.a
  8765.                              library                                  
  8766.      /usr/lib/libFORT_p.a    profiling combined extended Berkeley      
  8767.                              function                                 
  8768.      /usr/lib/libm_apc.a     standard NS32081 code math library       
  8769.      /usr/lib/libm_fpa.a     math library for APC02 systems with      
  8770.                              Cone processor                           
  8771.      /usr/lib/libm_xpc.a     XPC system math library (8 float-        
  8772.                              register, NS32381)                       
  8773.                                                                       
  8774. SEE ALSO                                                              
  8775.      as(1), cc(1), ld(1), m4(1), prof(1), sdb(1), cdb(1X),            
  8776.      efl(1F), fpr(1F) fsplit(1F) ratfor(1F), struct(1F),              
  8777.      intro(3F) epf(9F),                                               
  8778.       Fortran-77 Manual.                                              
  8779.                                                                       
  8780.      American National Standard Programming Language Fortran,         
  8781.      ANSI X3.9-1978.                                                  
  8782.                                NOTES
  8783. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  8784.                                NOTES
  8785. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  8786. APPENDIX G - lint
  8787.                                                                         
  8788. $man lint                                                             
  8789.                                                                       
  8790. NAME                                                                  
  8791.      lint - a C program checker                                       
  8792.                                                                       
  8793. SYNOPSIS                                                              
  8794.      lint [ option ] ... file ...                                     
  8795.                                                                       
  8796. DESCRIPTION                                                           
  8797.      lint attempts to detect features of the C program files that     
  8798.      are likely to be bugs, non-portable, or wasteful.  It also       
  8799.      checks type usage more strictly than the compilers.  Among       
  8800.      the things that are currently detected are unreachable           
  8801.      statements, loops not entered at the top, automatic              
  8802.      variables declared and not used, and logical expressions         
  8803.      whose value is constant.  Moreover, the usage of functions       
  8804.      is checked to find functions that return values in some          
  8805.      places and not in others, functions called with varying          
  8806.      numbers or types of arguments, and functions whose values        
  8807.      are not used or whose values are used but none returned.         
  8808.                                                                       
  8809.      Arguments whose names end with .c are taken to be C source       
  8810.      files.  Arguments whose names end with .ln are taken to be       
  8811.      the result of an earlier invocation of lint with either the      
  8812.      -c or the -o option used.  The .ln files are analogous to .o     
  8813.      (object) files that are produced by the cc(1) command when       
  8814.      given a .c file as input.  Files with other suffixes are         
  8815.      warned about and ignored.                                        
  8816.                                                                       
  8817.      lint will take all the .c, .ln, and llib-lx.ln (specified by     
  8818.      -lx) files and process them in their command line order.  By     
  8819.      default, lint appends the standard C lint library (llib-         
  8820.      lc.ln) to the end of the list of files.  However, if the -p      
  8821.      option is used, the portable C lint library (llib-port.ln)       
  8822.      is appended instead.  When the -c option is not used, the        
  8823.      second pass of lint checks this list of files for mutual         
  8824.      compatibility.  When the -c option is used, the .ln and the      
  8825.      llib-lx.ln files are ignored.                                    
  8826.                                                                       
  8827.      Any number of lint options may be used, in any order,            
  8828.      intermixed with file-name arguments.  The following options      
  8829.      are used to suppress certain kinds of complaints:                
  8830.                                                                       
  8831.      -a      Suppress complaints about assignments of long values     
  8832.              to variables that are not long.                          
  8833.                                                                       
  8834.      -b      Suppress complaints about break statements that          
  8835.              cannot be reached.  (Programs produced by lex(1) or      
  8836.              yacc(1) will often result in many such complaints.)      
  8837.                                                                       
  8838.      -h      Do not apply heuristic tests that attempt to intuit      
  8839.              bugs, improve style, and reduce waste.                   
  8840.                                                                       
  8841.      -u      Suppress complaints about functions and external         
  8842.              variables used and not defined, or defined and not       
  8843.              used.  (This option is suitable for running lint on      
  8844.              a subset of files of a larger program).                  
  8845.                                                                       
  8846.      -v      Suppress complaints about unused arguments in            
  8847.              functions.                                               
  8848.                                                                       
  8849.      -x      Do not report variables referred to by external          
  8850.              declarations but never used.                             
  8851.                                                                       
  8852.      The following arguments alter lint's behavior:                   
  8853.                                                                       
  8854.      -lx  Include additional lint library llib-lx.ln.  For            
  8855.           example, a lint version of the Math Library llib-lm.ln      
  8856.           can be included by inserting -lm on the command line.       
  8857.           This argument does not suppress the default use of          
  8858.           llib-lc.ln.  These lint libraries must be in the            
  8859.           assumed directory.  This option can be used to              
  8860.           reference local lint libraries and is useful in the         
  8861.           development of multi-file projects.                         
  8862.                                                                       
  8863.      -n   Do not check compatibility against either the standard      
  8864.           or the portable lint library.                               
  8865.                                                                       
  8866.      -p   Attempt to check portability to other dialects (IBM and     
  8867.           GCOS) of C.  Along with stricter checking, this option      
  8868.           causes all non-external names to be truncated to eight      
  8869.           characters and all external names to be truncated to        
  8870.           six characters and one case.                                
  8871.                                                                       
  8872.      -c   Cause lint to produce a .ln file for every .c file on       
  8873.           the command line.  These .ln files are the product of       
  8874.           lint's first pass only, and are not checked for inter-      
  8875.           function compatibility.                                     
  8876.                                                                       
  8877.      -o lib                                                           
  8878.           Cause lint to create a lint library with the name           
  8879.           llib-llib.ln.  The -c option nullifies any use of the       
  8880.           -o option.  The lint library produced is the input that     
  8881.           is given to lint's second pass.  The -o option simply       
  8882.           causes this file to be saved in the named lint library.     
  8883.           To produce a llib-llib.ln without extraneous messages,      
  8884.           use of the -x option is suggested.  The -v option is        
  8885.           useful if the source file(s) for the lint library are       
  8886.           just external interfaces (for example, the way the file     
  8887.           llib-lc is written).  These option settings are also        
  8888.           available through the use of "lint comments" (see           
  8889.           below).                                                     
  8890.                                                                       
  8891.      The -D, -U, and -I options of cc(1) and cpp(1) and the -g        
  8892.      and -O options of cc are also recognized as separate             
  8893.      arguments.  The -g and -O options are ignored, but, by           
  8894.      recognizing these options, lint's behavior is closer to that     
  8895.      of the cc command.  Other options are warned about and           
  8896.      ignored.  The pre-processor symbol "lint" is defined to          
  8897.      allow certain questionable code to be altered or removed for     
  8898.      lint.  Therefore, the symbol "lint" should be thought of as      
  8899.      a reserved word for all code that is planned to be checked       
  8900.      by lint.                                                         
  8901.                                                                       
  8902.      Certain conventional comments in the C source will change        
  8903.      the behavior of lint:                                            
  8904.                                                                       
  8905.      /*NOTREACHED*/                                                   
  8906.           at appropriate points stops comments about unreachable      
  8907.           code.  (This comment is typically placed just after         
  8908.           calls to functions like exit(2).)                           
  8909.                                                                       
  8910.      /*VARARGSn*/                                                     
  8911.           suppresses the usual checking for variable numbers of        
  8912.           arguments in the following function declaration.  The        
  8913.           data types of the first n arguments are checked; a
  8914.           missing n is taken to be 0.                                  
  8915.                                                                        
  8916.      /*ARGSUSED*/                                                      
  8917.           turns on the -v option for the next function.                
  8918.                                                                        
  8919.      /*LINTLIBRARY*/                                                   
  8920.           at the beginning of a file shuts off complaints about        
  8921.           unused functions and function arguments in this file.        
  8922.           This is equivalent to using the -v and -x options.           
  8923.                                                                        
  8924.      lint produces its first output on a per-source-file basis.        
  8925.      Complaints regarding included files are collected and             
  8926.      printed after all source files have been processed.               
  8927.      Finally, if the -c option is not used, information gathered       
  8928.      from all input files is collected and checked for                 
  8929.      consistency.  At this point, if it is not clear whether a
  8930.      complaint stems from a given source file or from one of its      
  8931.      included files, the source file name will be printed             
  8932.      followed by a question mark.                                     
  8933.                                                                       
  8934.      The behavior of the -c and the -o options allows for             
  8935.      incremental use of lint on a set of C source files.              
  8936.      Generally, one invokes lint once for each source file with       
  8937.      the -c option.  Each of these invocations produces a .ln         
  8938.      file which corresponds to the .c file, and prints all            
  8939.      messages that are about just that source file.  After all        
  8940.      the source files have been separately run through lint, it       
  8941.      is invoked once more (without the -c option), listing all        
  8942.      the .ln files with the needed -lx options.  This will print      
  8943.      all the inter-file inconsistencies.  This scheme works well      
  8944.      with make(1); it allows make to be used to lint only the         
  8945.      source files that have been modified since the last time the     
  8946.      set of source files were linted.                                 
  8947.                                                                       
  8948. FILES                                                                 
  8949.      /usr/lib/lint[12]        first and second passes                 
  8950.      /usr/lib/llib-lc.ln      declarations for C Library              
  8951.                               functions (binary format; source is     
  8952.                               in /usr/lib/llib-lc)                    
  8953.      /usr/lib/llib-port.ln    declarations for portable functions     
  8954.                               (binary format; source is in            
  8955.                               /usr/lib/llib-port)                     
  8956.      /usr/lib/llib-lm.ln      declarations for Math Library           
  8957.                               functions (binary format; source is     
  8958.                               in /usr/lib/llib-lm.ln)                 
  8959.      /usr/tmp/*lint*          temporaries                             
  8960.                                                                       
  8961. SEE ALSO                                                              
  8962.      cc(1), cpp(1), lex(1), make(1), yacc(1), tmpnam(3S).             
  8963.                                                                       
  8964. BUGS                                                                  
  8965.      exit(2), longjmp(3C), and other functions that do not return     
  8966.      are not understood; this causes various lies.                    
  8967. APPENDIX H - cb
  8968.  
  8969. $man cb                                                                 
  8970.                                                                         
  8971. NAME                                                                    
  8972.      cb - C program beautifier                                         
  8973.                                                                        
  8974. SYNOPSIS                                                               
  8975.      cb [ -s ] [ -j ] [ -l leng ] [ file ... ]                         
  8976.                                                                        
  8977. DESCRIPTION                                                            
  8978.      The cb comand reads C programs either from its arguments or       
  8979.      from the standard input, and writes them on the standard          
  8980.      output with spacing and indentation that display the              
  8981.      structure of the code.  Under default options, cb preserves       
  8982.      all user new-lines.                                               
  8983.                                                                        
  8984.      cb accepts the following options.                                 
  8985.                                                                        
  8986.      -s        Canonicalizes the code to the style of Kernighan        
  8987.                and Ritchie in The C Programming Language.              
  8988.                                                                        
  8989.      -j        Causes split lines to be put back together.             
  8990.                                                                        
  8991.       -l leng  Causes cb to split lines that are longer than           
  8992.                leng.                                                   
  8993.                                                                        
  8994. SEE ALSO                                                               
  8995.      cc(1).                                                            
  8996.      The C Programming Language.  Prentice-Hall, 1978.                 
  8997.                                                                        
  8998. BUGS                                                                   
  8999.      Punctuation that is hidden in preprocessor statements will        
  9000.      cause indentation errors.                                         
  9001.                                NOTES
  9002. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  9003. APPENDIX I - ar
  9004.  
  9005. $man ar                                                                  
  9006.                                                                        
  9007. NAME                                                                   
  9008.      ar - archive and library maintainer for portable archives         
  9009.                                                                        
  9010. SYNOPSIS                                                               
  9011.      ar key [ posname ] afile [ name ] ...                             
  9012.                                                                        
  9013. DESCRIPTION                                                            
  9014.      The ar command maintains groups of files combined into a
  9015.      single archive file.  Its main use is to create and update      
  9016.      library files as used by the link editor.  It can be used,      
  9017.      though, for any similar purpose.  The magic string and the      
  9018.      file headers used by ar consist of printable ASCII              
  9019.      characters.  If an archive is composed of printable files,      
  9020.      the entire archive is printable.                                
  9021.                                                                      
  9022.      When ar creates an archive, it creates headers in a format      
  9023.      that is portable across all machines.  The portable archive     
  9024.      format and structure is described in detail in ar(4).  The      
  9025.      archive symbol table (described in ar(4)) is used by the        
  9026.      link editor (ld(1)) to effect multiple passes over libraries    
  9027.      of object files in an efficient manner.  An archive symbol      
  9028.      table is only created and maintained by ar when there is at     
  9029.      least one object file in the archive.  The archive symbol       
  9030.      table is in a specially named file which is always the first    
  9031.      file in the archive.  This file is never mentioned or           
  9032.      accessible to the user.  Whenever the ar command is used to     
  9033.      create or update the contents of such an archive, the symbol    
  9034.      table is rebuilt.  The s option described below will force      
  9035.      the symbol table to be rebuilt. The symbol table holds a
  9036.      maximum of 20,000 symbols.                                       
  9037.                                                                       
  9038.      Unlike command options, the command key is a required part       
  9039.      of ar's command line.  The key (which may begin with a -) is     
  9040.      formed with one of the following letters:  drqtpmx.              
  9041.      Arguments to the key, alternatively, are made with one of        
  9042.      more of the following set:  vuaibcls.  posname is an archive     
  9043.      member name used as a reference point in positioning other       
  9044.      files in the archive.  afile is the archive file.  The names     
  9045.      are constituent files in the archive file.  The meanings of      
  9046.      the key characters are as follows:                               
  9047.                                                                       
  9048.      d    Delete the named files from the archive file.               
  9049.                                                                       
  9050.      r    Replace the named files in the archive file.  If the        
  9051.           optional character u is used with r, then only those        
  9052.           files with dates of modification later than the archive     
  9053.           files are replaced.  If an optional positioning             
  9054.           character from the set aib is used, then the posname        
  9055.           argument must be present and specifies that new files       
  9056.           are to be placed after (a) or before (b or i) posname.      
  9057.           Otherwise new files are placed at the end.                  
  9058.                                                                       
  9059.      q    Quickly append the named files to the end of the            
  9060.           archive file.  Optional positioning characters are          
  9061.           invalid.  The command does not check whether the added      
  9062.           members are already in the archive. This option is          
  9063.           useful to avoid quadratic behavior when creating a
  9064.           large archive piece-by-piece.  Unchecked, the file may      
  9065.           grow exponentially up to the second degree.                 
  9066.                                                                       
  9067.      t    Print a table of contents of the archive file.  If no       
  9068.           names are given, all files in the archive are tabled.       
  9069.           If names are given, only those files are tabled.            
  9070.                                                                       
  9071.      p    Print the named files in the archive.                       
  9072.                                                                       
  9073.      m    Move the named files to the end of the archive.  If a
  9074.           positioning character is present, then the posname          
  9075.           argument must be present and, as in r, specifies where      
  9076.           the files are to be moved.                                  
  9077.                                                                       
  9078.      x    Extract the named files.  If no names are given, all        
  9079.           files in the archive are extracted.  In neither case        
  9080.           does x alter the archive file.                              
  9081.                                                                       
  9082.      The meanings of the key arguments are as follows:                
  9083.                                                                       
  9084.      v    Give a verbose file-by-file description of the making       
  9085.           of a new archive file from the old archive and the          
  9086.           constituent files.  When used with t, give a long           
  9087.           listing of all information about the files.  When used      
  9088.           with x, precede each file with a name.                      
  9089.                                                                       
  9090.      c    Suppress the message that is produced by default when       
  9091.           afile is created.                                           
  9092.                                                                       
  9093.      l    Place temporary files in the local (current working)        
  9094.           directory, rather than in the default temporary             
  9095.           directory, /tmp.                                             
  9096.                                                                        
  9097.      s    Force the regeneration of the archive symbol table even      
  9098.           if ar is not invoked with a command which will modify        
  9099.           the archive contents.  This command is useful to             
  9100.           restore the archive symbol table after the strip(1)          
  9101.           command has been used on the archive.                        
  9102.                                                                        
  9103. SEE ALSO                                                               
  9104.      ld(1), lorder(1), strip(1), tmpnam(3S), a.out(4), ar(4).          
  9105.      "The Common Object File Format" in the UMAX V Programmer's        
  9106.      Guide.                                                            
  9107.                                                                        
  9108.  
  9109. BUGS                                                                   
  9110.      If the same file is mentioned twice in an argument list, it       
  9111.      may be put in the archive twice.                                  
  9112.                                                                        
  9113.                                                                               
  9114.                                                                
  9115. NAME                                                                   
  9116.      ar - common archive file format                                   
  9117.                                                                        
  9118. DESCRIPTION                                                            
  9119.      The archive command ar(1) combines several files into one.        
  9120.      Archives are used mainly as libraries to be searched by the       
  9121.      link editor ld(1).                                                
  9122.                                                                        
  9123.      Each archive begins with the archive magic string:                
  9124.                                                                        
  9125.      #define  ARMAG     "!<arch>\n"   /* magic string */               
  9126.      #define  SARMAG    8             /* length of magic string */     
  9127.                                                                        
  9128.      Each archive that contains common object files (see               
  9129.      a.out(4)) includes an archive symbol table.  The link editor      
  9130.      ld uses the symbol table to determine which archive members       
  9131.      Each archive that contains common object files (see               
  9132.      a.out(4)) includes an archive symbol table.  The link editor      
  9133.      ld uses the symbol table to determine which archive members       
  9134.      must be loaded during the link edit process.  The archive         
  9135.      symbol table (if it exists) is always the first file in the       
  9136.      archive (but is never listed) and is automatically created        
  9137.      and updated by ar.                                                
  9138.                                                                        
  9139.      Following the archive magic string are the archive file           
  9140.      members.  Each file member is preceded by a file member           
  9141.      header in the following format:                                   
  9142.                                                                        
  9143.      #define ARFMAG            "`\n"  /* header trailer string */      
  9144.      struct  ar_hdr {                 /* file member header */         
  9145.              char ar_date[12];        /* file member date */           
  9146.                                       member name */                   
  9147.              char ar_gid[6];          /* file member group             
  9148.                                       identification */                
  9149.              char ar_mode[8];         /* file member mode              
  9150.                                       (octal) */                       
  9151.              char ar_size[10];        /* file member size */           
  9152.              char ar_fmag[2];         /* header trailer string */      
  9153.      };                                                                
  9154.                                                                        
  9155.      All information in the file member headers is in printable        
  9156.      ASCII .  The numeric information in the headers is stored as      
  9157.      decimal numbers (except for ar_mode, which is in octal).          
  9158.      Thus, if the archive contains printable files, the archive        
  9159.      itself is printable.                                              
  9160.  
  9161.                                                                        
  9162.      The ar_name field is blank-padded and terminated with a
  9163.      slash (/).  The ar_date field is the modification date of         
  9164.      the file at the time it is inserted into the archive.             
  9165.      Common format archives can be moved from system to system as      
  9166.      long as the portable archive command ar is used.                  
  9167.                                                                        
  9168.      Each archive file member begins on an even byte boundary; a
  9169.      newline is inserted between files if necessary.                  
  9170.      Nevertheless the size given reflects the actual size of the      
  9171.      file exclusive of padding.                                       
  9172.                                                                       
  9173.      Notice there is no provision for empty areas in an archive       
  9174.      file.                                                            
  9175.                                                                       
  9176.      If the archive symbol table exists, the first file in the        
  9177.      archive has a zero length name (that is, ar_name[0] == '/').     
  9178.      The contents of this file are:                                   
  9179.                                                                       
  9180.           The number of symbols.  Length: 4 bytes.                    
  9181.                                                                       
  9182.           The array of offsets into the archive file.  Length: 4      
  9183.           bytes * "the number of symbols".                            
  9184.                                                                       
  9185.           The name string table.  Length:  ar_size - (4 bytes *       
  9186.           ("the number of symbols" + 1)).                             
  9187.                                                                       
  9188.      The string table contains exactly as many null-terminated        
  9189.      strings as there are elements in the offsets array.  Each        
  9190.      offset from the array is associated with the corresponding       
  9191.      name from the string table (in order).  The names in the         
  9192.      string table are all the defined global symbols found in the     
  9193.      common object files in the archive.  Each offset is the          
  9194.      location of the archive header for the associated symbol.        
  9195.                                                                       
  9196. SEE ALSO                                                              
  9197.      ar(1), ld(1), strip(1), ldahread(3X), ldfcn(4), a.out(4).        
  9198.                                                                       
  9199. CAVEATS                                                               
  9200.      strip removes all archive symbol entries from the header.        
  9201.      The archive symbol entries must be restored with the ts          
  9202.      option of ar command before the archive can be used with the     
  9203.      link editor ld.                                                  
  9204.                                NOTES
  9205. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  9206.                                NOTES
  9207. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  9208. APPENDIX J - time
  9209.  
  9210. $man time                                                                  
  9211.                                                                        
  9212. NAME                                                                   
  9213.      time - get time                                                   
  9214.                                                                        
  9215. SYNOPSIS                                                               
  9216.      #include <sys/types.h>                                            
  9217.                                                                        
  9218.      time_t time (tloc)                                                
  9219.      time_t *tloc;                                                     
  9220.                                                                        
  9221. DESCRIPTION                                                            
  9222.      time returns the value of time in seconds since 00:00:00          
  9223.      GMT, January 1, 1970.                                             
  9224.                                                                        
  9225.      If tloc is not a null pointer, the return value is also           
  9226.      stored in the location to which tloc points.                      
  9227.                                                                        
  9228.      time will fail if the following is true:                          
  9229.                                                                        
  9230.      [EFAULT]  points to an illegal address.                           
  9231.                                                                        
  9232. SEE ALSO                                                               
  9233.      stime(2).                                                         
  9234.                                                                        
  9235. DIAGNOSTICS                                                            
  9236.      Upon successful completion, time returns the value of time.       
  9237.      Otherwise, a value of -1 is returned and errno is set to          
  9238.      indicate the error.                                               
  9239.                                                                        
  9240.                                                                        
  9241. NAME                                                                   
  9242.      time, ctime, ltime, gmtime - return system time                   
  9243.                                                                        
  9244. SYNOPSIS                                                               
  9245.      integer function time() character*(*) function ctime (stime       
  9246.      integer stime subroutine ltime (stime, tarray)                    
  9247.      integer stime, tarray(9) subroutine gmtime (stime, tarray)        
  9248.      integer stime, tarray(9)                                          
  9249.                                                                        
  9250. DESCRIPTION                                                            
  9251.      Time returns the time since 00:00:00 GMT, Jan 1, 1970,            
  9252.      measured in seconds.  This is the value of the system clock       
  9253.                                                                        
  9254.      Ctime converts a system time to a 24-character ASCII string       
  9255.      The format is described under ctime(3).  No newline or NULL       
  9256.      is included.                                                      
  9257.                                                                        
  9258.      Ltime and gmtime both disect a time field into month, day,        
  9259.      etc., either for the local time zone or for GMT.  The order       
  9260.      and meaning of each element returned in tarray is described       
  9261.      under ctime(3).                                                   
  9262.                                                                        
  9263. FILES                                                                  
  9264.      /usr/lib/libU77.a
  9265.                                                                       
  9266. SEE ALSO                                                              
  9267.      ctime(3), itime(3F), idate(3F), fdate(3F)                        
  9268.                                                                       
  9269.                                                                       
  9270. NAME                                                                  
  9271.      time - time a command                                            
  9272.                                                                       
  9273. SYNOPSIS                                                              
  9274.      time command                                                     
  9275.                                                                       
  9276. DESCRIPTION                                                           
  9277.      The command is executed; after it is complete, time prints       
  9278.      the elapsed time during the command, the time spent in the       
  9279.      system, and the time spent in execution of the command.          
  9280.      Times are reported in seconds.                                   
  9281.                                                                       
  9282.      The times are printed on standard error.                         
  9283.                                                                       
  9284. SEE ALSO                                                              
  9285.      timex(1).                                                        
  9286.      times(2) in the UMAX V Programmer's Reference Manual.            
  9287. APPENDIX K - ksh
  9288.  
  9289. $man ksh                                                                 
  9290.                                                                       
  9291. NAME                                                                  
  9292.      ksh, rksh - korn shell, a command programming language           
  9293.                                                                       
  9294. SYNOPSIS                                                              
  9295.      ksh [ -acefhikmnorstuvx ] [ -o option ] ... [ arg ... ]          
  9296.      rksh [ -acefhikmnorstuvx ] [ -o option ] ... [ arg ... ]         
  9297.                                                                       
  9298. DESCRIPTION                                                           
  9299.      ksh is a command programming language that executes commands     
  9300.      read from a terminal or a file.  rksh is a restricted            
  9301.      version of the standard command interpreter ksh; it is used      
  9302.      to set up login names and execution environments whose           
  9303.      capabilities are more controlled than those of the standard      
  9304.      shell.  See Invocation below for the meaning of arguments to     
  9305.      the shell.                                                       
  9306.                                                                       
  9307.      ksh is close to being upwards compatible with the standard       
  9308.      Bourne shell (sh(1)).  Its major enhancements include            
  9309.      command re-entry, in-line command editing, and aliasing.         
  9310.                                                                       
  9311.    Definitions.                                                       
  9312.      A metacharacter is one of the following characters:              
  9313.                                                                       
  9314.           ; & ( ) | < > new-line space tab                            
  9315.                                                                       
  9316.      A blank is a tab or a space.  An identifier is a sequence of     
  9317.      letters, digits, or underscores starting with a letter or        
  9318.      underscore.  Identifiers are used as names for aliases,          
  9319.      functions, and named parameters.  A word is a sequence of        
  9320.      characters separated by one or more non-quoted                   
  9321.      metacharacters.                                                  
  9322.                                                                       
  9323.    Commands.                                                          
  9324.      A simple-command is a sequence of blank separated words           
  9325.      which may be preceded by a parameter assignment list.  (See       
  9326.      Environment below).  The first word specifies the name of         
  9327.      the command to be executed.  Except as specified below, the       
  9328.      remaining words are passed as arguments to the invoked            
  9329.      command.  The command name is passed as argument 0 (see           
  9330.      exec(2)).  The value of a simple-command is its exit status       
  9331.      if it terminates normally, or (octal) 200+status if it            
  9332.      terminates abnormally (see signal(2) for a list of status         
  9333.      values).                                                          
  9334.                                                                        
  9335.      A pipeline is a sequence of one or more commands separated        
  9336.      |.  The standard output of each command but the last is           
  9337.      connected by a pipe(2) to the standard input of the next          
  9338.      command.  Each command is run as a separate process; the          
  9339.      shell waits for the last command to terminate.  The exit          
  9340.      status of a pipeline is the exit status of the last command.      
  9341.      A list is a sequence of one or more pipelines separated by        
  9342.      ;, &, &&, or ||, and optionally terminated by ;, &, or |&.        
  9343.      Of these five symbols, ;, &, and |& have equal precedence,        
  9344.      which is lower than that of && and ||.  The symbols && and        
  9345.      || also have equal precedence.  A semicolon (;) causes            
  9346.      sequential execution of the preceding pipeline; an ampersand      
  9347.      (&) causes asynchronous execution of the preceding pipeline       
  9348.      (i.e., the shell does not wait for that pipeline to finish).      
  9349.      The symbol |& causes asynchronous execution of the preceding      
  9350.      command or pipeline with a two-way pipe established to the        
  9351.      parent shell.  The standard input and output of the spawned       
  9352.      command can be written to and read from by the parent shell       
  9353.      using the -p option of the special commands read and print        
  9354.      described later.  Only one such command can be active at any      
  9355.      given time.  The symbol && (||) causes the list following it      
  9356.      to be executed only if the preceding pipeline returns a zero      
  9357.      (non-zero) value.  An arbitrary number of new-lines may           
  9358.      appear in a list, instead of semicolons, to delimit               
  9359.      commands.                                                         
  9360.                                                                        
  9361.      A command is either a simple-command or one of the                
  9362.      following.  Unless otherwise stated, the value returned by a
  9363.      command is that of the last simple-command executed in the        
  9364.      command.                                                          
  9365.                                                                        
  9366.      for identifier [ in word ... ] do list done                       
  9367.           Each time a for command is executed, identifier is set       
  9368.           to the next word taken from the in word list.  If in         
  9369.           word ...  is omitted, then the for command executes the      
  9370.           do list once for each positional parameter that is set       
  9371.           (see Parameter Substitution below).  Execution ends          
  9372.           when there are no more words in the list.                    
  9373.                                                                        
  9374.      select identifier [ in word ... ] do list done                    
  9375.           A select command prints on standard error (file              
  9376.           descriptor 2), the set of words, each preceded by a
  9377.           number.  If in word ...  is omitted, then the                
  9378.           positional parameters are used instead (see Parameter        
  9379.           Substitution below).  The PS3 prompt is printed and a
  9380.           line is read from the standard input.  If this line         
  9381.           consists of the number of one of the listed words, then     
  9382.           the value of the parameter identifier is set to the         
  9383.           word corresponding to this number.  If this line is         
  9384.           empty, the selection list is printed again.  Otherwise      
  9385.           the value of the parameter identifier is set to null.       
  9386.           The contents of the line read from standard input is        
  9387.           saved in the parameter REPLY.  The list is executed for     
  9388.           each selection until a break or end-of-file is              
  9389.           encountered.                                                
  9390.                                                                       
  9391.      case word in [ pattern [ | pattern ] ... ) list ;; ] ... esac
  9392.           A case command executes the list associated with the    
  9393.           first pattern that matches word.  The form of the            
  9394.           patterns is the same as that used for file-name              
  9395.           generation (see File Name Generation below).                 
  9396.                                                                        
  9397.     if list then list [ elif list then list ] ... [ else list ] fi     
  9398.           The list following if is executed and, if it returns a
  9399.           zero exit status, the list following the first then is       
  9400.           executed.  Otherwise, the list following elif is             
  9401.           executed and, if its value is zero, the list following       
  9402.           the next then is executed.  Failing that, the else list      
  9403.           is executed.  If no else list or then list is executed,      
  9404.           then the if command returns a zero exit status.              
  9405.                                                                        
  9406.      while list do list done                                           
  9407.      until list do list done                                           
  9408.           A while command repeatedly executes the while list and,      
  9409.           if the exit status of the last command in the list is        
  9410.           zero, executes the do list; otherwise the loop               
  9411.           terminates.  If no commands in the do list are               
  9412.           executed, then the while command returns a zero exit         
  9413.           status; until may be used in place of while to negate        
  9414.           the loop termination test.                                   
  9415.                                                                        
  9416.      (list)                                                            
  9417.           Execute list in a separate environment.  Note, that if       
  9418.           two adjacent open parentheses are needed for nesting, a
  9419.           space must be inserted to avoid arithmetic evaluation        
  9420.           as described below.                                          
  9421.                                                                        
  9422.      {list;}                                                           
  9423.           list is simply executed.  Note that { is a keyword and       
  9424.           requires a blank in order to be recognized.                  
  9425.                                                                        
  9426.      function identifier  { list ;}                                    
  9427.      identifier  () { list ;}                                          
  9428.           Define a function which is referenced by identifier.         
  9429.           The body of the function is the list of commands             
  9430.           between { and }.  (See Functions below).                     
  9431.                                                                        
  9432.      time pipeline                                                    
  9433.           The pipeline is executed and the elapsed time as well       
  9434.           as the user and system time are printed on standard         
  9435.           error.                                                      
  9436.                                                                       
  9437.      The following keywords are only recognized as the first word     
  9438.      of a command and when not quoted:                                
  9439.                                                                       
  9440.      if then else elif fi case esac for while until do done { }       
  9441.      function select time                                             
  9442.                                                                       
  9443.    Comments.                                                          
  9444.      A word beginning with # causes that word and all the             
  9445.      following characters up to a new-line to be ignored.             
  9446.                                                                       
  9447.    Aliasing.                                                          
  9448.      The first word of each command is replaced by the text of an     
  9449.      alias if an alias for this word has been defined.  The first     
  9450.      character of an alias name can be any printable character,       
  9451.      but the rest of the characters must be the same as for a
  9452.      valid identifier.  The replacement string can contain any        
  9453.      valid shell script including the metacharacters listed           
  9454.      above.  The first word of each command of the replaced text      
  9455.      will not be tested for additional aliases.  If the last          
  9456.      character of the alias value is a blank then the word            
  9457.      following the alias will also be checked for alias               
  9458.      substitution.  Aliases can be used to redefine special           
  9459.      built-in commands but cannot be used to redefine the             
  9460.      keywords listed above.  Aliases can be created, listed, and      
  9461.      exported with the alias command and can be removed with the      
  9462.      unalias command.  Exported aliases remain in effect for          
  9463.      sub-shells but must be reinitialized for separate                
  9464.      invocations of the shell (See Invocation below).                 
  9465.                                                                       
  9466.      Aliasing is performed when scripts are read, not while they      
  9467.      are executed.  Therefore, for an alias to take effect the        
  9468.      alias command has to be executed before the command which        
  9469.      references the alias is read.                                    
  9470.                                                                       
  9471.      Aliases are frequently used as a short hand for full path        
  9472.      names.  An option to the aliasing facility allows the value      
  9473.      of the alias to be automatically set to the full path name       
  9474.      of the corresponding command.  These aliases are called          
  9475.      tracked aliases.  The value of a tracked alias is defined        
  9476.      the first time the identifier is read and undefined each         
  9477.      time the PATH variable is reset.  These aliases remain           
  9478.      tracked so that the next subsequent reference will redefine      
  9479.      the value.  Several tracked aliases are compiled into the        
  9480.      shell.  The -h option of the set command makes each command      
  9481.      name which is an identifier into a tracked alias.                
  9482.                                                                       
  9483.      The following exported aliases are compiled into the shell       
  9484.      but can be unset or redefined:                                   
  9485.                                                                       
  9486.                          echo='print -'                               
  9487.                          false='let 0'                                
  9488.                          functions='typeset -f'                       
  9489.                          history='fc -l'                              
  9490.                          integer='typeset -i'                         
  9491.                          nohup='nohup '                               
  9492.                          pwd='print - $PWD'                            
  9493.                          r='fc -e -'                                   
  9494.                          true=':'                                       
  9495.                          type='whence -v'                               
  9496.                          hash='alias -t'                                
  9497.                                                                         
  9498.  
  9499.    Tilde Substitution.                                                  
  9500.      After alias substitution is performed, each word is checked        
  9501.      to see if it begins with an unquoted ~.  If it does, then          
  9502.      the word up to a / is checked to see if it matches a user          
  9503.      name in the /etc/passwd file.  If a match is found, the ~          
  9504.      and the matched login name is replaced by the login                
  9505.      directory of the matched user.  This is called a tilde            
  9506.      substitution.  If no match is found, the original text is         
  9507.      left unchanged.  A ~ by itself, or in front of a /, is            
  9508.      replaced by the value of the HOME parameter.  A ~ followed        
  9509.      by a + or - is replaced by the value of the parameter PWD         
  9510.      and OLDPWD respectively.                                          
  9511.                                                                        
  9512.      In addition, the value of each keyword parameter is checked       
  9513.      to see if it begins with a ~ or if a ~ appears after a :.         
  9514.      In either of these cases a tilde substitution is attempted.       
  9515.                                                                        
  9516.    Command Substitution.                                               
  9517.      The standard output from a command enclosed in a pair of          
  9518.      grave accents (``) may be used as part or all of a word;          
  9519.      trailing new-lines are removed.  The command substitution        
  9520.      `cat file` can be replaced by the equivalent but faster          
  9521.      `<file>`.  Command substitution of most special commands         
  9522.      that do not perform input/output redirection are carried out     
  9523.      without creating a separate process.                             
  9524.                                                                       
  9525.    Parameter Substitution.                                            
  9526.      A parameter is an identifier, a digit, or any of the             
  9527.      characters *, @, #, ?, -, $, and !.  A named parameter (a
  9528.      parameter denoted by an identifier) has a value and zero or      
  9529.      more attributes.  Named parameters can be assigned values        
  9530.      and attributes by using the typeset special command.  The        
  9531.      attributes supported by the shell are described later with       
  9532.      the typeset special command.  Exported parameters pass           
  9533.      values and attributes to sub-shells but only values to the       
  9534.      environment.                                                     
  9535.                                                                       
  9536.      The shell supports a limited one-dimensional array facility.     
  9537.      An element of an array parameter is referenced by a
  9538.      subscript.  A subscript is denoted by a [, followed by an        
  9539.      arithmetic expression (see Arithmetic Evaluation below)          
  9540.      followed by a ].  The value of all subscripts must be in the     
  9541.      range of 0 through 511.  Arrays need not be declared.  Any       
  9542.      reference to a named parameter with a valid subscript is         
  9543.      legal and an array will be created if necessary.                 
  9544.      Referencing an array without a subscript is equivalent to        
  9545.      referencing the first element.                                   
  9546.                                                                       
  9547.      The value of a named parameter may also be assigned by           
  9548.      writing:                                                         
  9549.                                                                       
  9550.           name=value [ name=value ] ...                               
  9551.                                                                       
  9552.      If the integer attribute, -i, is set for name the value is       
  9553.      subject to arithmetic evaluation as described below.             
  9554.      Positional parameters, parameters denoted by a number, may       
  9555.      be assigned values with the set special command.  Parameter      
  9556.      $0 is set from argument zero when the shell is invoked.          
  9557.      The character $ is used to introduce substitutable               
  9558.      parameters.                                                      
  9559.      ${parameter}                                                     
  9560.           The value, if any, of the parameter is substituted.         
  9561.           The braces are required when parameter is followed by a
  9562.           letter, digit, or underscore that is not to be              
  9563.           interpreted as part of its name or when a named             
  9564.           parameter is subscripted.  If parameter is a digit then     
  9565.           it is a positional parameter.  If parameter is * or @,      
  9566.           then all the positional parameters, starting with $1,       
  9567.           are substituted (separated by spaces).  If an array         
  9568.           identifier with subscript * or @ is used, then the          
  9569.           value for each of the elements is substituted               
  9570.           (separated by spaces).                                      
  9571.      ${#parameter}                                                    
  9572.           If parameter is not *, the length of the value of the       
  9573.           parameter is substituted.  Otherwise, the number of         
  9574.           positional parameters is substituted.                       
  9575.      ${#identifier[*]}                                                
  9576.           The number of elements in the array identifier is           
  9577.           substituted.                                                
  9578.      ${parameter:-word}                                               
  9579.           If parameter is set and is non-null then substitute its     
  9580.           value; otherwise substitute word.                           
  9581.      ${parameter:=word}                                               
  9582.           If parameter is not set or is null then set it to word;     
  9583.           the value of the parameter is then substituted.             
  9584.           Positional parameters may not be assigned to in this        
  9585.           way.                                                        
  9586.      ${parameter:?word}                                               
  9587.           If parameter is set and is non-null then substitute its     
  9588.           value; otherwise, print word and exit from the shell.       
  9589.           If word is omitted then a standard message is printed.      
  9590.      ${parameter:+word}                                               
  9591.           If parameter is set and is non-null then substitute         
  9592.           word; otherwise substitute nothing.                         
  9593.      ${parameter#pattern}                                             
  9594.      ${parameter##pattern}                                            
  9595.           If the shell pattern matches the beginning of the value     
  9596.           of parameter, then the value of this substitution is        
  9597.           the value of the parameter with the matched portion         
  9598.           deleted; otherwise, the value of this parameter is          
  9599.           substituted.  In the first form the smallest matching       
  9600.           pattern is deleted and in the latter form the largest       
  9601.           matching pattern is deleted.                                
  9602.                                                                       
  9603.      ${parameter%pattern}                                             
  9604.      ${parameter%%pattern}                                            
  9605.           If the shell pattern matches the end of the value of        
  9606.           parameter, then the value of parameter with the matched     
  9607.           part is deleted; otherwise substitute the value of          
  9608.           parameter.  In the first form the smallest matching         
  9609.           pattern is deleted and in the latter form the largest       
  9610.           matching pattern is deleted.                                
  9611.                                                                       
  9612.      In the above, word is not evaluated unless it is to be used      
  9613.      as the substituted string, so that, in the following             
  9614.      example, pwd is executed only if d is not set or is null:        
  9615.                                                                       
  9616.           echo ${d:-`pwd`}                                            
  9617.                                                                       
  9618.      If the colon (:) is omitted from the above expressions, then     
  9619.      the shell only checks whether parameter is set or not.           
  9620.      If the shell pattern matches the end of the value of             
  9621.      parameter, then the value of parameter with the matched          
  9622.      part is deleted; otherwise substitute the value of               
  9623.      parameter.  In the first form the smallest matching              
  9624.      pattern is deleted and in the latter form the largest            
  9625.      matching pattern is deleted.                                     
  9626.                                                                       
  9627. In the above, word is not evaluated unless it is to be used           
  9628. as the substituted string, so that, in the following                  
  9629. example, pwd is executed only if d is not set or is null:             
  9630.                                                                       
  9631.      echo ${d:-`pwd`}                                                 
  9632.                                                                       
  9633. If the colon (:) is omitted from the above expressions, then          
  9634. the shell only checks whether parameter is set or not.                
  9635.                                                                       
  9636. The following parameters are automatically set by the shell:          
  9637.      #    The number of positional parameters in decimal.             
  9638.      -    Flags supplied to the shell on invocation or by             
  9639.           the set command.                                            
  9640.      ?    The decimal value returned by the last executed             
  9641.           command.                                                    
  9642.      $    The process number of this shell.                           
  9643.      _    The last argument of the previous command.  This            
  9644.           parameter is not set for commands which are                  
  9645.           asynchronous.                                                
  9646.      !    The process number of the last background command            
  9647.           invoked.                                                     
  9648.      PPID The process number of the parent of the shell.               
  9649.      PWD  The present working directory set by the cd                  
  9650.           command.                                                    
  9651.      OLDPWD                                                           
  9652.           The previous working directory set by the cd                
  9653.           command.                                                    
  9654.      RANDOM                                                           
  9655.           Each time this parameter is referenced, a random            
  9656.           integer is generated.  The sequence of random               
  9657.           numbers can be initialized by assigning a numeric           
  9658.           initialized by assigning a numeric value to                 
  9659.      RANDOM.                                                          
  9660.           Each time this parameter is referenced, a random            
  9661.           integer is generated.  The sequence of random               
  9662.           numbers can be initialized by assigning a numeric           
  9663.           to RANDOM.                                                  
  9664.      REPLY                                                            
  9665.           This parameter is set by the select statement and           
  9666.           by the read special command when no arguments are           
  9667.           supplied.                                                   
  9668.                                                                       
  9669. The following parameters are used by the shell:                       
  9670.      CDPATH                                                           
  9671.           The search path for the cd command.                         
  9672.      COLUMNS                                                          
  9673.           If this variable is set, the value is used to               
  9674.           define the width of the edit window for the shell           
  9675.           edit modes and for printing select lists.                   
  9676.      EDITOR                                                           
  9677.           If the value of this variable ends in emacs,                
  9678.           gmacs, or vi and the VISUAL variable is not set,            
  9679.           then the corresponding option (see Special                  
  9680.           Commands set below) will be turned on.                      
  9681.      ENV  If this parameter is set, then parameter                    
  9682.           substitution is performed on the value to generate          
  9683.           the  path name of the script that will be executed          
  9684.           when the shell is invoked.  (See Invocation                 
  9685.           below.) This file is typically used for alias and           
  9686.           function definitions.                                       
  9687.      FCEDIT                                                           
  9688.           The default editor name for the fc command.                 
  9689.      IFS  Internal field separators, normally space, tab,             
  9690.           and new-line that is used to separate command               
  9691.           words which result from command or parameter                
  9692.           substitution and for separating words with  the             
  9693.           special command read.                                       
  9694.      HISTFILE                                                         
  9695.           If this parameter is set when the shell is                  
  9696.           invoked, then the value is the path name of the             
  9697.           file that will be used to store the command                 
  9698.           history.  (See Command Re-entry below.)                     
  9699.      HISTSIZE                                                         
  9700.           If this parameter is set when the shell is                  
  9701.           invoked, then the number of previously entered              
  9702.           commands that are accessible by this shell will be          
  9703.           greater than or equal to this number.  The default          
  9704.           is 128.                                                     
  9705.      HOME The default argument (home directory) for the cd            
  9706.           command.                                                    
  9707.      MAIL If this parameter is set to the name of a mail              
  9708.           file and the MAILPATH parameter is not set, then            
  9709.           the shell informs the user of arrival of mail in            
  9710.           the specified file.                                         
  9711.      MAILCHECK                                                        
  9712.           This variable specifies how often (in seconds) the          
  9713.           shell will check for changes in the modification            
  9714.           time of any of the files specified by the MAILPATH          
  9715.           or MAIL parameters.  The default value is 600               
  9716.           seconds.  If set to 0, the shell will check before          
  9717.           each prompt.                                                
  9718.      MAILPATH                                                         
  9719.           A colon ( : ) separated list of file names.  If             
  9720.           this parameter is set then the shell informs the            
  9721.           user of any modifications to the specified files            
  9722.           that have occurred within the last MAILCHECK                
  9723.           seconds.  Each file name can be followed by a ?             
  9724.           and a message that will be printed.  The message            
  9725.           will undergo parameter and command substitution             
  9726.           with the parameter, $_ defined as the name of the           
  9727.           file that has changed.  The default message is you          
  9728.           have mail in $_.                                            
  9729.      PATH The search path for commands (see Execution                 
  9730.           below).  The user may not change PATH if executing          
  9731.           under rksh (except in .profile).                            
  9732.      PS1  The value of this parameter is expanded for                 
  9733.           parameter substitution to define the primary                
  9734.           prompt string which by default is "$ ".  The                
  9735.           character !  in the primary prompt string is                
  9736.           replaced by the command number (see Command Re-             
  9737.           entry below).                                               
  9738.      PS2  Secondary prompt string, by default "> ".                   
  9739.      PS3  Selection prompt string used within a select loop,          
  9740.           by default "#? ".                                           
  9741.      SHELL                                                            
  9742.           The path name of the shell is kept in the                   
  9743.           environment.  At invocation, if the value of this           
  9744.           variable contains an r in the basename, then the            
  9745.           shell becomes restricted.                                   
  9746.      TMOUT                                                            
  9747.           If set to a value greater than zero, the shell              
  9748.           will terminate if a command is not entered within           
  9749.           the prescribed number of seconds.  When the timer           
  9750.           expires, a warning is printed and a 60 second               
  9751.           grace period is provided.                                   
  9752.     VISUAL                                                            
  9753.           If the value of this variable ends in emacs,                
  9754.           gmacs, or vi then the corresponding option (see             
  9755.           Special Commands set below) will be turned on.              
  9756.                                                                       
  9757. The shell gives default values to PS1, PS2, MAILCHECK,                
  9758. TMOUT, and IFS.  HOME, MAIL, SHELL, PATH, and TZ are set by           
  9759. login(1).  The remaining parameters are typically set in              
  9760. /etc/profile, .profile, or $(ENV) files.                              
  9761.                                                                       
  9762. After parameter and command substitution, the results of              
  9763. substitutions are scanned for the field separator characters          
  9764. ( those found in IFS ) and split into distinct arguments              
  9765. where such characters are found.  Explicit null arguments ""          
  9766. or ' ' are retained.  Implicit null arguments (those                  
  9767. resulting from parameters that have no values) are removed.           
  9768.                                                                       
  9769. Following substitution, each command word is scanned for the          
  9770. characters *, ?, and [ unless the -f option has been set.             
  9771. If one of these characters appears then the word is regarded          
  9772. as a pattern.  The word is replaced with alphabetically               
  9773. sorted file names that match the pattern.  If no file name            
  9774. is found that matches the pattern, then the word is left              
  9775. unchanged.  When a pattern is used for file name generation,          
  9776. the character . at the start of a file name or immediately            
  9777. following a /, as well as the character / itself, must be             
  9778. matched explicitly.  In other instances of pattern matching           
  9779. the / and . are not treated specially.                                
  9780.                                                                       
  9781.      *    Matches any string, including the null string.              
  9782.      ?    Matches any single character.                               
  9783.      [...]                                                            
  9784.           Matches any one of the enclosed characters.  A
  9785.             
  9786.           pair of characters separated by - matches any                
  9787.           character lexically between the pair, inclusive.             
  9788.           If the first character following the opening [ is            
  9789.           a !, then any character not enclosed is matched.             
  9790.           A - can be included in the character set by                  
  9791.           putting it as the first or last character.                   
  9792.                                                                        
  9793. Each of the metacharacters listed above (See Definitions               
  9794. above) has a special meaning to the shell and causes                   
  9795. termination of a word unless quoted.  A character may be               
  9796. quoted (i.e., made to stand for itself) by preceding it with           
  9797. a \.  The pair \new-line is ignored.  All characters                   
  9798. enclosed between a pair of single quote marks (''), except a
  9799. single quote, are quoted.  Inside double quote marks (""),             
  9800. parameter and command substitution occurs and \ quotes the             
  9801. characters \, ', ", and $.  $* is equivalent to "$1 $2 ...",           
  9802. whereas $@ is equivalent to $1  $2  ....                               
  9803.                                                                        
  9804. The special meaning of keywords can be removed by quoting              
  9805. any character of the keyword.  The recognition of special              
  9806. command names listed below cannot be altered by quoting                
  9807. them.                                                                  
  9808.                                                                        
  9809. An ability to perform integer arithmetic is provided with              
  9810. the special command let.  Evaluations are performed using              
  9811. long arithmetic.  Constants are of the form [base#]n where             
  9812. base is a decimal number between two and thirty-six                    
  9813. representing the arithmetic base and n is a number in that             
  9814. base.  If the base is omitted them base 10 is used.                    
  9815.                                                                        
  9816. An internal integer representation of a named parameter can            
  9817. be specified with the -i option of the typeset special                 
  9818. command.  When this attribute is selected the first                    
  9819. assignment to the parameter determines the arithmetic base             
  9820. to be used when parameter substitution occurs.                         
  9821.                                                                        
  9822. Since many of the arithmetic operators require quoting, an             
  9823. alternative form of the let command is provided.  For any              
  9824. command which begins with a ((, all the characters until a
  9825. matching )) are treated as a quoted expression.  More                  
  9826. precisely, ((...)) is equivalent to let " ...".                         
  9827.                                                                         
  9828. When used interactively, the shell prompts with the value of            
  9829. PS1 before reading a command.  If at any time a new-line is             
  9830. typed and further input is needed to complete a command,                
  9831. then the secondary prompt (i.e., the value of PS2) is                   
  9832. issued.                                                                 
  9833.                                                                         
  9834. Before a command is executed, its input and output may be               
  9835. redirected using a special notation interpreted by the                  
  9836. shell.  The following may appear anywhere in a simple-                  
  9837. command or may precede or follow a command and are not                  
  9838. passed on to the invoked command.  Command and parameter                
  9839. substitution occurs before word or digit is used except as              
  9840. noted below.  File name generation occurs only if the                   
  9841. pattern matches a single file and blank interpretation is               
  9842. not performed.                                                          
  9843.                                                                         
  9844. <word         Use file word as standard input (file                     
  9845.               descriptor 0).                                            
  9846.                                                                         
  9847. >word         Use file word as standard output (file                    
  9848.               descriptor 1).  If the file does not exist                
  9849.               then it is created; otherwise, it is truncated            
  9850.               to zero length.                                           
  9851.                                                                         
  9852. >>word        Use file word as standard output.  If the file            
  9853.               exists then output is appended to it (by first            
  9854.               seeking to the end-of-file); otherwise, the               
  9855.               file is created.                                          
  9856.                                                                         
  9857. <<[-]word     The shell input is read up to a line that is              
  9858.               the same as word, or to an end-of-file.  No              
  9859.               parameter substitution, command substitution             
  9860.               or file name generation is performed on word.            
  9861.               The resulting document, called a here-                   
  9862.               document, becomes the standard input.  If any            
  9863.               character of word is quoted, no interpretation           
  9864.               is placed upon the characters of the document;           
  9865.               otherwise, parameter and command substitution            
  9866.               occurs, \new-line is ignored, and \ must be              
  9867.               used to quote the characters \, $, `, and the            
  9868.               first character of word.  If - is appended to            
  9869.               <<, all leading tabs are stripped from word              
  9870.               and from the document.                                   
  9871.                                                                        
  9872. <&digit       The standard input is duplicated from file               
  9873.               descriptor digit (see dup(2)).  Similarly for            
  9874.               the standard output using >& digit.                      
  9875.                                                                        
  9876. <&-           The standard input is closed.  Similarly for             
  9877.               the standard output using >&-.                           
  9878.                                                                        
  9879. If one of the above is preceded by a digit, then the file              
  9880. descriptor number referred to is that specified by the digit           
  9881. (instead of the default 0 or 1).  For example:                         
  9882.                                                                        
  9883.      ... 2>&1                                                          
  9884.                                                                        
  9885. means file descriptor 2 is to be opened for writing as a
  9886. duplicate of file descriptor 1.                                        
  9887.                                                                        
  9888. The order in which redirections are specified is                       
  9889. significant.  The shell evaluates each redirection in terms            
  9890. of the (file descriptor, file) association at the time of              
  9891. evaluation.  For example:                                              
  9892.                                                                        
  9893.      ... 1>fname 2>&1                                                  
  9894.                                                                        
  9895. first associates file descriptor 1 with file fname.  It then           
  9896. associates file descriptor 2 with the file associated with             
  9897. file descriptor 1 (i.e. fname).  If the order of                       
  9898. redirections were reversed, file descriptor 2 would be                 
  9899. associated with the terminal (assuming file descriptor 1 had           
  9900. been) and then file descriptor 1 would be associated with              
  9901. file fname.                                                            
  9902.                                                                        
  9903. If a command is followed by & and job control is not active,           
  9904. then the default standard input for the command is the empty           
  9905. file /dev/null.  Otherwise, the environment for the                    
  9906. execution of a command contains the file descriptors of the            
  9907. invoking shell as modified by input/output specifications.             
  9908.                                                                        
  9909. The environment (see environ(5)) is a list of name-value               
  9910. pairs that is passed to an executed program in the same way            
  9911. as a normal argument list.  The names must be identifiers              
  9912. and the values are character strings.  The shell interacts             
  9913. with the environment in several ways.  On invocation, the              
  9914. shell scans the environment and creates a parameter for each           
  9915. name found, giving it the corresponding value and marking it           
  9916. export.  Executed commands inherit the environment.  If the            
  9917. user modifies the values of these parameters or creates new            
  9918. ones, using the export or typeset -x commands they become              
  9919. part of the environment.  The environment seen by any                  
  9920. executed command is thus composed of any name-value pairs              
  9921. originally inherited by the shell, whose values may be                 
  9922. modified by the current shell, plus any additions which must           
  9923. be noted in export or typeset -x commands.                             
  9924.                                                                        
  9925. The environment for any simple-command or function may be              
  9926. augmented by prefixing it with one or more parameter                   
  9927. assignments.  A parameter assignment argument is a word of             
  9928. the form identifier=value.  Thus:                                      
  9929.                                                                        
  9930.      TERM=450 cmd args                  and                            
  9931.                                                                        
  9932.      (export TERM; TERM=450; cmd args)                                 
  9933.                                                                        
  9934.      are equivalent (as far as the above execution of cmd is           
  9935.      concerned).                                                       
  9936.                                                                        
  9937.      If the -k flag is set, all parameter assignment arguments         
  9938.      are placed in the environment, even if they occur after the       
  9939.      command name.  The following first prints a=b c and then c:       
  9940.                                                                        
  9941.              echo a=b c                                                
  9942.              set -k                                                    
  9943.              echo a=b c                                                
  9944.                                                                        
  9945.    Functions.                                                          
  9946.      The function keyword, described in the Commands section           
  9947.      above, is used to define shell functions.  Shell functions        
  9948.      are read in and stored internally.  Alias names are resolved      
  9949.      when the function is read.  Functions are executed like           
  9950.      commands with the arguments passed as positional parameters.      
  9951.      (See Execution below).                                            
  9952.                                                                        
  9953.      Functions execute in the same process as the caller and           
  9954.      share all files, traps (other than EXIT and ERR) and present      
  9955.      working directory with the caller.  A trap set on EXIT            
  9956.      inside a function is executed after the function completes.       
  9957.      Ordinarily, variables are shared between the calling program      
  9958.      and the function.  However, the typeset special command used      
  9959.      within a function defines local variables whose scope             
  9960.      includes the current function and all functions it calls.         
  9961.                                                                        
  9962.      The special command return is used to return from function        
  9963.      calls.  Errors within functions return control to the             
  9964.      caller.                                                           
  9965.                                                                        
  9966.      Function identifiers can be listed with the -f option of the      
  9967.      typeset special command.  The text of functions will also be      
  9968.      listed.  Function can be undefined with the -f option of the      
  9969.      unset special command.                                            
  9970.                                                                      
  9971.      Ordinarily, functions are unset when the shell executes a
  9972.      shell script.  The -xf option of the typeset command allows       
  9973.      a function to be exported to scripts that are executed            
  9974.      without a separate invocation of the shell.  Functions that       
  9975.      need to be defined across separate invocations of the shell       
  9976.      should be placed in the ENV file.                                        
  9977.                                                               
  9978.    Jobs.                                                               
  9979.      If the monitor option of the set command is turned on, a
  9980.      terminating background job is so noted whenever ksh is  
  9981.      writing a prompt.  When a job is started asynchronously with      
  9982.      &, the shell prints a line which looks like:                      
  9983.                                                                        
  9984.           [1] 1234                                                     
  9985.                                                                        
  9986.      indicating that the job started asynchronously was job            
  9987.      number 1 and had one (top-level) process, whose process id        
  9988.      was 1234.  It keeps a table of current jobs, printed by the       
  9989.      jobs command, and assigns them small integer numbers.             
  9990.                                                                        
  9991.      There are several ways to refer to jobs in the shell.  The        
  9992.      character % introduces a job name.  When referring to job         
  9993.      number 1, name it as %1.  Jobs can also be named by prefixes      
  9994.      of the string typed in to invoke them.  Thus, 'kill %cc'          
  9995.      would kill a background job whose name began with the string      
  9996.      "cc" (if there were such a job).                                  
  9997.                                                                        
  9998.      The shell maintains a notion of the current and previous          
  9999.      jobs.  In output pertaining to jobs, the current job is           
  10000.      marked with a + and the previous job with a -.  The               
  10001.      abbreviation %+ refers to the current job and %- refers to        
  10002.      the previous job.  %% is also a synonym for the current job.      
  10003.                                                                        
  10004.      This shell learns immediately whenever a process changes          
  10005.      state.  It normally informs the user whenever a job is            
  10006.      finished executing, but only just before it prints a prompt.      
  10007.      This is done so that it does not otherwise disturb other          
  10008.      work.                                                            
  10009.                                                                       
  10010.      When attempting to leave a login shell while jobs are            
  10011.      running, be warning will be printed that 'You have running       
  10012.      jobs'.  Use the jobs command to see what they are.  If           
  10013.      immediately trying exit again, the shell will give a second      
  10014.      warning, and the jobs will be terminated.                        
  10015.                                                                       
  10016.    Job Control.                                                       
  10017.      If a job is running, a ^Z <ctrl>Z can be typed which sends a
  10018.      STOP signal to the current job.  The shell will then             
  10019.      normally indicate that the job has been 'Stopped', and print     
  10020.      another prompt.  The state of this job can then be               
  10021.      manipulated using the bg command, or running some other          
  10022.      commands and then eventually bring the job back into the         
  10023.      foreground with the foreground command fg.  A ^Z takes           
  10024.      effect immediately and is like an interrupt in that pending      
  10025.      output and unread input are discarded when it is typed.          
  10026.                                                                       
  10027.      A job being run in the background will stop if it tries to       
  10028.      read from the terminal.  Background jobs are normally            
  10029.      allowed to produce output, but this can be disabled by           
  10030.      giving the command stty tostop.  If this tty option is set,      
  10031.      background jobs will stop when they try to produce output        
  10032.      like they do when they try to read input.                        
  10033.                                                                       
  10034.    Signals.                                                           
  10035.      The INT and QUIT signals for an invoked command are ignored      
  10036.      if the command is followed by & and job monitor option is        
  10037.      not active.  Otherwise, signals have the values inherited by     
  10038.      the shell from its parent, with the exception of signal 11       
  10039.      (but see also the trap command below).                           
  10040.    Execution.                                                         
  10041.      Each time a command is executed, the above substitutions are     
  10042.      carried out.  If the command name matches one of the Special     
  10043.      Commands listed below, it is executed within the current         
  10044.      shell process.  Next, the command name is checked to see if      
  10045.      it matches one of the user defined functions.  If it does,       
  10046.      the positional parameters are saved and then reset to the        
  10047.      arguments of the function call.  When the function completes     
  10048.      or issues a return, the positional parameter list is             
  10049.      restored and any trap set on EXIT within the function is         
  10050.      executed.  The value of a function is the value of the last      
  10051.      command executed.  A function is also executed in the            
  10052.      current shell process.  If a command name is not a special       
  10053.      command or a user defined function, a process is created and     
  10054.      an attempt is made to execute the command via exec(2).           
  10055.                                                                       
  10056.      The shell parameter PATH defines the search path for the         
  10057.      directory containing the command.  Alternative directory         
  10058.      names are separated by a colon (:).  The default path is         
  10059.      :/bin:/usr/bin (specifying the current directory, /bin, and      
  10060.      /usr/bin, in that order).  Note that the current directory       
  10061.      is specified by a null path name, which can appear               
  10062.      immediately after the equal sign, between colon delimiters,      
  10063.      or at the end of the path list.  If the command name             
  10064.      contains a / then the search path is not used.  Otherwise,       
  10065.      each directory in the path is searched for an executable         
  10066.      file.  If the file has execute permission but is not a
  10067.      directory or an a.out file, it is assumed to be a file           
  10068.      containing shell commands.  A sub-shell is spawned to read       
  10069.      it.  All non-exported aliases, functions, and named              
  10070.      parameters are removed in this case.  A parenthesized            
  10071.      command is also executed in a sub-shell.                         
  10072.                                                                       
  10073.    Command Re-entry.                                                  
  10074.      The text of the last HISTSIZE (default 128) commands entered     
  10075.      from a terminal device is saved in a history file.  The file     
  10076.      $HOME/.history is used if the HISTFILE variable is not set       
  10077.      or is not writable.  A shell can access the commands of all      
  10078.      interactive shells which use the same named HISTFILE.  The       
  10079.      special command fc is used to list or edit a portion this        
  10080.      file.  The portion of the file to be edited or listed can be     
  10081.      selected by number or by giving the first character or           
  10082.      characters of the command.  A single command or range of         
  10083.      commands can be specified.  If an editor program is not          
  10084.      specified as an argument to fc, the value of the parameter       
  10085.      FCEDIT is used.  If FCEDIT is not defined, /bin/ed is used.      
  10086.      The edited command(s) is printed and re-executed upon            
  10087.      leaving the editor.  The editor name - is used to skip the       
  10088.      editing phase and to re-execute the command.  In this case a
  10089.      substitution parameter of the form old=new can be used to        
  10090.      modify the command before execution.  For example, if r is       
  10091.      aliased to 'fc -e -' typing 'r bad=good c' will re-execute       
  10092.      the most recent command which starts with the letter c,          
  10093.      replacing the string bad with the string good.                   
  10094.                                                                       
  10095.    In-line Editing Options                                            
  10096.      Normally, each command line entered from a terminal device       
  10097.      is simply typed followed by a new-line ('RETURN' or              
  10098.      'LINE FEED').  If either the emacs, or vi option is active,      
  10099.      the user can edit the command line.  To be in either of          
  10100.      these edit modes set the corresponding option.  An editing       
  10101.      option is automatically selected each time the VISUAL or         
  10102.      EDITOR variable is assigned a value ending in either of          
  10103.      these option names.                                              
  10104.                                                                       
  10105.      The editing features require that the user's terminal accept     
  10106.      'RETURN' as carriage return without line feed and that a
  10107.      space '  ' must overwrite the current character on the           
  10108.      screen.  ADM terminal users should set the "space - advance"     
  10109.      switch to 'space'.  Hewlett-Packard series 2621 terminal         
  10110.      users should set the straps to 'bcGHxZ etX'.                     
  10111.                                                                       
  10112.      The editing modes implement a concept where the user is          
  10113.      looking through a window at the current line.  The window        
  10114.      width is the value of COLUMNS if it is defined, otherwise        
  10115.      80.  If the line is longer than the window width minus two,      
  10116.      a mark is displayed at the end of the window to notify the       
  10117.      user.  As the cursor moves and reaches the window boundaries     
  10118.      the window will be centered about the cursor.  The mark is a
  10119.      > ( <, *) if the line extends on the right (left, both)          
  10120.      side(s) of the window.                                           
  10121.                                                                       
  10122.    Emacs Editing Mode                                                 
  10123.      This mode is entered by enabling either the emacs or gmacs       
  10124.      option.  The only difference between these two modes is the      
  10125.      way they handle ^T.  To edit, the user moves the cursor to       
  10126.      the point needing correction and then inserts or deletes         
  10127.      characters or words as needed.  All the editing commands are     
  10128.      control characters or escape sequences.  The notation for        
  10129.      control characters is caret () followed by the character.        
  10130.      For example, ^F is the notation for control F.  This is          
  10131.      entered by depressing 'f' while holding down the 'CTRL'          
  10132.      (control) key.  The 'SHIFT' key is not depressed.  (The          
  10133.      notation ^? indicates the DEL (delete) key.)                     
  10134.                                                                       
  10135.      The notation for escape sequences is M- followed by a
  10136.      character.  For example, M-f (pronounced Meta f) is entered       
  10137.      by depressing ESC (ascii 033 ) followed by 'f'.  ( M-F would      
  10138.      be the notation for ESC followed by 'SHIFT' (capital) 'F'.)       
  10139.      All edit commands operate from any place on the line (not         
  10140.      just at the beginning).  Neither the "RETURN" nor the "LINE       
  10141.      FEED" key is entered after edit commands except when noted.       
  10142.                                                                        
  10143.      ^F        Move cursor forward (right) one character.              
  10144.      M-f       Move cursor forward one word.  (The editor's idea
  10145.                of a word is a string of characters consisting of       
  10146.                only letters, digits and underscores.)                  
  10147.      ^B        Move cursor backward (left) one character.              
  10148.      M-b       Move cursor backward one word.                          
  10149.      ^A        Move cursor to start of line.                           
  10150.      ^E        Move cursor to end of line.                             
  10151.      ^]char    Move cursor to character char on current line.          
  10152.      ^X^X      Interchange the cursor and mark.                        
  10153.      erase     (User defined erase character as defined by the         
  10154.                stty command, usually ^H or #.) Delete previous         
  10155.                character.                                              
  10156.      ^D        Delete current character.                               
  10157.      M-d       Delete current word.                                    
  10158.      M-^H      (Meta-backspace) Delete previous word.                  
  10159.      M-h       Delete previous word.                                   
  10160.      M-^?      (Meta-DEL) Delete previous word (if the interrupt       
  10161.                character is ^? (DEL, the default) then this            
  10162.                command will not work).                                 
  10163.      ^T        Transpose current character with next character in      
  10164.                emacs mode.  Transpose two previous characters in       
  10165.                gmacs mode.                                             
  10166.      ^C        Capitalize current character.                           
  10167.      M-C       Capitalize current word.                                
  10168.      ^K        Kill from the cursor to the end of the line.  If        
  10169.                given a parameter of zero then kill from the start      
  10170.                of line to the cursor.                                  
  10171.      ^W        Kill from the cursor to the mark.                       
  10172.      M-p       Push the region from the cursor to the mark on the      
  10173.                stack.                                                  
  10174.      kill      (User defined kill character as defined by the          
  10175.                stty command, usually ^G or @.) Kill the entire         
  10176.                current line.  If two kill characters are entered       
  10177.                in succession, all kill characters from then on         
  10178.                cause a line feed (useful when using paper              
  10179.                terminals).                                             
  10180.      ^Y        Restore last item removed from line. (Yank item         
  10181.                back to the line.)                                      
  10182.      ^L        Line feed and print current line.                       
  10183.      ^@        (Null character) Set mark.                              
  10184.      M-        (Meta space) Set mark.                                  
  10185.      ^J        (New line)  Execute the current line.                   
  10186.      ^M        (Return)  Execute the current line.                     
  10187.      eof       End-of-file character, normally ^D, will terminate      
  10188.                the shell if the current line is null.                  
  10189.      ^P        Fetch previous command. Each time ^P is entered         
  10190.                the previous command back in time is accessed.          
  10191.      M-<       Fetch the least recent (oldest) history line.           
  10192.      M->       Fetch the most recent (youngest) history line.          
  10193.      ^N        Fetch next command. Each time ^N is entered the         
  10194.                next command forward in time is accessed.               
  10195.      ^Rstring  Reverse search history for a previous command line      
  10196.                containing string.  If a parameter of zero is           
  10197.                given the search is forward.  String is terminated      
  10198.                by a "RETURN" or "NEW LINE".                            
  10199.      ^O        Operate - Execute the current line and fetch the        
  10200.                next line relative to current line from the             
  10201.                history file.                                           
  10202.      M-digits  (Escape) Define numeric parameter, the digits are       
  10203.                taken as a parameter to the next command.  The          
  10204.                commands that accept a parameter are ^F, ^B,            
  10205.                erase, ^D, ^K, ^R, ^P and ^N.                           
  10206.      M-letter  Soft-key - The alias list is searched for an alias      
  10207.                by the name _letter and if an alias of this name        
  10208.                is defined, its value will be inserted on the           
  10209.                line.  The letter must not be one of the above          
  10210.                meta-functions.                                         
  10211.      M-_       The last parameter of the previous command is           
  10212.                inserted on the line.                                   
  10213.      M-.       The last parameter of the previous command is           
  10214.                inserted on the line.                                   
  10215.      M-*       Attempt file name generation on the current word.       
  10216.      ^U        Multiply parameter of next command by 4.                
  10217.      \         Escape next character.  Editing characters, the         
  10218.                user's erase, kill and interrupt (normally ^? )         
  10219.                characters may be entered in a command line or in       
  10220.                a search string if preceded by a \.  The \ removes      
  10221.                the next character's editing features (if any).         
  10222.      ^V        Display version of the shell.                           
  10223.                                                                        
  10224.    vi Editing Mode                                                     
  10225.      There are two typing modes.  Initially, when entering a
  10226.      command the user is in the input mode.  To edit, the user         
  10227.      enters control mode by typing ESC ( 033 ) and moves the           
  10228.      cursor to the point needing correction and then inserts or        
  10229.      deletes characters or words as needed.  Most control              
  10230.      commands accept an optional repeat count prior to the             
  10231.      command.                                                          
  10232.                                                                        
  10233.      When in vi mode on most systems, canonical processing is          
  10234.      initially enabled and the command will be echoed again if         
  10235.      the speed is 1200 baud or greater and it contains any             
  10236.      control characters or less than one second has elapsed since      
  10237.      the prompt was printed.  The ESC character terminates             
  10238.      canonical processing for the remainder of the command and         
  10239.      the user can then modify the command line.  This scheme has       
  10240.      the advantages of canonical processing with the type-ahead        
  10241.      echoing of raw mode.                                              
  10242.                                                                        
  10243.      If the option viraw is also set, the terminal will always         
  10244.      have canonical processing disabled.  This mode may be             
  10245.      helpful for certain terminals.                                    
  10246.                                                                        
  10247.    Input Edit Commands                                                 
  10248.      By default the editor is in input mode.                           
  10249.                                                                        
  10250.      erase     (User defined erase character as defined by the         
  10251.                stty command, usually ^H or #.) Delete previous         
  10252.                character.                                              
  10253.      ^W        Delete the previous blank separated word.               
  10254.      ^D        Terminate the shell.                                    
  10255.      ^V        Escape next character.  Editing characters, the         
  10256.                user's erase or kill characters may be entered in       
  10257.                a command line or in a search string if preceded        
  10258.                by a ^V.  The ^V removes the next character's           
  10259.                editing features (if any).                              
  10260.      \         Escape the next erase or kill character.                
  10261.                                                                        
  10262.                                                                        
  10263.    Motion Edit Commands                                                
  10264.      These commands will move the cursor.                              
  10265.                                                                        
  10266.      [count]l  Cursor forward (right) one character.                   
  10267.      [count]w  Cursor forward one alpha-numeric word.                  
  10268.      [count]W  Cursor to the beginning of the next word that           
  10269.                follows a blank.                                        
  10270.      [count]e  Cursor to end of word.                                  
  10271.      [count]E  Cursor to end of the current blank delimited word.      
  10272.      [count]h  Cursor backward (left) one character.                   
  10273.      [count]b  Cursor backward one word.                               
  10274.      [count]B  Cursor to preceding blank separated word.               
  10275.      [count]fc Find the next character c in the current line.          
  10276.      [count]Fc Find the previous character c in the current line.      
  10277.      [count]tc Equivalent to f followed by h.                          
  10278.      [count]Tc Equivalent to F followed by l.                          
  10279.      ;         Repeats the last single character find command, f,      
  10280.                F, t, or T.                                             
  10281.      ,         Reverses the last single character find command.        
  10282.      0         Cursor to start of line.                                
  10283.      ^         Cursor to first non-blank character in line.            
  10284.      $         Cursor to end of line.                                  
  10285.                                                                        
  10286.    Search Edit Commands                                                
  10287.      These commands access the command history.                        
  10288.                                                                        
  10289.      [count]k  Fetch previous command. Each time k is entered the      
  10290.                previous command back in time is accessed.              
  10291.      [count]-  Equivalent to k.                                        
  10292.      [count]j  Fetch next command. Each time j is entered the          
  10293.                next command forward in time is accessed.               
  10294.      [count]+  Equivalent to j.                                        
  10295.      [count]G  The command number count is fetched.  The default       
  10296.                is the least recent history command.                    
  10297.      /string   Search backward through history for a previous          
  10298.                command containing string.  String is terminated        
  10299.                by a "RETURN" or "NEW LINE".  If string is null         
  10300.                the previous string will be used.                       
  10301.      ?string   Same as / except that search will be in the             
  10302.                forward direction.                                      
  10303.      n         Search for next match of the last pattern to / or       
  10304.                ? commands.                                             
  10305.      N         Search for next match of the last pattern to / or       
  10306.                ?, but in reverse direction.  Search history for        
  10307.                the string entered by the previous / command.           
  10308.                                                                        
  10309.    Text Modification Edit Commands                                     
  10310.      These commands will modify the line.                              
  10311.                                                                        
  10312.      a         Enter input mode and enter text after the current       
  10313.                character.                                              
  10314.      A         Append text to the end of the line.  Equivalent to      
  10315.                $a.                                                     
  10316.      [count]cmotion                                                    
  10317.      c[count]motion                                                    
  10318.                Delete current character through the character          
  10319.                motion moves the cursor to and enter input mode.        
  10320.                If motion is c, the entire line will be deleted         
  10321.                and input mode entered.                                 
  10322.      C         Delete the current character through the end of         
  10323.                line and enter input mode.  Equivalent to c$.           
  10324.      S         Equivalent to cc.                                       
  10325.      D         Delete the current character through the end of         
  10326.                line.                                                   
  10327.      [count]dmotion                                                    
  10328.      d[count]motion                                                    
  10329.                Delete current character through the character          
  10330.                motion moves the cursor to.  Equivalent to d$.  If      
  10331.                motion is d , the entire line will be deleted.          
  10332.      i         Enter input mode and insert text before the             
  10333.                current character.                                      
  10334.      I         Insert text before the beginning of the line.           
  10335.                Equivalent to the two character sequence ^i.            
  10336.      [count]P  Place the previous text modification before the         
  10337.                cursor.                                                 
  10338.      [count]p  Place the previous text modification after the          
  10339.                cursor.                                                 
  10340.      R         Enter input mode and replace characters on the          
  10341.                screen with characters typed in overlay fashion.        
  10342.      rc        Replace the current character with c.                   
  10343.      [count]x  Delete current character.                               
  10344.      [count]X  Delete preceding character.                             
  10345.      [count].  Repeat the previous text modification command.          
  10346.      ~         Invert the case of the current character and            
  10347.                advance the cursor.                                     
  10348.      [count]_  Causes the count word of the previous command to        
  10349.                be appended and input mode entered.  The last word      
  10350.                is used if count is omitted.                            
  10351.      *         Causes an * to be appended to the current word and      
  10352.                file name generation attempted.  If no match is         
  10353.                found, it rings the bell.  Otherwise, the word is       
  10354.                replaced by the matching pattern and input mode is      
  10355.                entered.                                                
  10356.                                                                        
  10357.    Other Edit Commands                                                 
  10358.      Miscellaneous commands.                                           
  10359.                                                                        
  10360.      u         Undo the last text modifying command.                   
  10361.      U         Undo all the text modifying commands performed on       
  10362.                the line.                                               
  10363.      [count]v  Returns the command fc -e ${VISUAL:-${EDITOR:-vi}}      
  10364.                count in the input buffer.  If count is omitted,        
  10365.                then the current line is used.                          
  10366.      ^L        Line feed and print current line.  Has effect only      
  10367.                in control mode.                                        
  10368.      ^J        (New line)  Execute the current line, regardless        
  10369.                of mode.                                                
  10370.      ^M        (Return)  Execute the current line, regardless of       
  10371.                mode.                                                   
  10372.      #         Equivalent to I#<cr>.  Useful for causing the           
  10373.                current line to be inserted in the history without      
  10374.                being executed.                                         
  10375.                                                                        
  10376.    Special Commands.                                                   
  10377.      The following simple-commands are executed in the shell           
  10378.      process.  Input/Output redirection is permitted.  File            
  10379.      descriptor 1 is the default output location.  Parameter           
  10380.      assignment lists preceding the command do not remain in           
  10381.      effect when the command completes unless noted.                   
  10382.                                                                        
  10383.      : [ arg ... ]                                                     
  10384.           Parameter assignments remain in effect after the             
  10385.           command completes.  The command only expands                 
  10386.           parameters.  A zero exit code is returned.                   
  10387.                                                                        
  10388.      .  file [ arg ... ]                                               
  10389.           Parameter assignments remain in effect after the             
  10390.           command completes.  Read and execute commands from file      
  10391.           and return.  The commands are executed in the current        
  10392.           shell environment.  The search path specified by PATH        
  10393.           is used to find the directory containing file.  If any       
  10394.           arguments arg are given, they become the positional          
  10395.           parameters.  Otherwise the positional parameters are         
  10396.           unchanged.                                                   
  10397.                                                                        
  10398.      alias [ -tx ] [ name[ =value ]  ... ]                             
  10399.  
  10400.           Alias with no arguments prints the list of aliases in        
  10401.           the form name=value on standard output.  An alias is         
  10402.           defined for each name whose value is given.  A trailing      
  10403.           space in value causes the next word to be checked for        
  10404.           list tracked aliases.  The value of a tracked alias is       
  10405.           the full path name corresponding to the given name.          
  10406.           The value becomes undefined when the value of PATH is        
  10407.           reset but the aliases remained tracked.  Without the -t      
  10408.           flag, for each name in the argument list for which no        
  10409.           value is given, the name and value of the alias is           
  10410.           printed.  The -x flag is used to set or print exported       
  10411.           aliases.  An exported alias is defined across sub-shell      
  10412.           environments.  Alias returns true unless a name is           
  10413.           given for which no alias has been defined.                   
  10414.                                                                        
  10415.      bg [ %job ]                                                       
  10416.           This command is only built-in on systems that support        
  10417.           job control.  Puts the specified job into the                
  10418.           background.  The current job is put in the background        
  10419.           if job is not specified.                                     
  10420.                                                                        
  10421.      break [ n ]                                                       
  10422.           Exit from the enclosing for while until or select loop,      
  10423.           if any.  If n is specified then break n levels.              
  10424.                                                                        
  10425.      continue [ n ]                                                    
  10426.           Resume the next iteration of the enclosing for while         
  10427.           until or select loop.  If n is specified then resume at      
  10428.           the n-th enclosing loop.                                     
  10429.      cd [ arg ]                                                        
  10430.      cd  old new                                                       
  10431.           This command can be in either of two forms.  In the          
  10432.           first form it changes the current directory to arg.  If      
  10433.           arg is - the directory is changed to the previous            
  10434.           directory.  The shell parameter HOME is the default          
  10435.           arg.  The parameter PWD is set to the current                
  10436.           directory.  The shell parameter CDPATH defines the           
  10437.           search path for the directory containing                     
  10438.           arg.Alternativedirectorynamesare a colon (:).  The           
  10439.           default path is <null> (specifying the current               
  10440.           directory).  Note that the current directory is              
  10441.           specified by a null path name, which can appear              
  10442.           immediately after the equal sign or between the colon        
  10443.           delimiters anywhere else in the path list.  If arg           
  10444.           begins with a / then the search path is not used.            
  10445.           Otherwise, each directory in the path is searched for        
  10446.           arg.                                                         
  10447.                                                                        
  10448.           The second form of cd substitutes the string new for         
  10449.           the string old in the current directory name, PWD and        
  10450.           tries to change to this new directory.                       
  10451.                                                                        
  10452.           The cd command may not be executed by rksh.                  
  10453.                                                                        
  10454.      eval [ arg ... ]                                                  
  10455.           The arguments are read as input to the shell and the         
  10456.           resulting command(s) executed.                               
  10457.                                                                        
  10458.      exec [ arg ... ]                                                  
  10459.           Parameter assignments remain in effect after the             
  10460.           command completes.  If arg is given, the command            
  10461.           specified by the arguments is executed in place of this     
  10462.           shell without creating a new process.  Input/output         
  10463.           arguments may appear and affect the current process.        
  10464.           If no arguments are given, the effect of this command       
  10465.           is to modify file descriptors as prescribed by the          
  10466.           input/output redirection list.  In this case, any file      
  10467.           descriptor numbers greater than 2 that are opened with      
  10468.           this mechanism are closed when invoking another             
  10469.           program.
  10470.                                                                       
  10471.      exit [n ]                                          
  10472.           Causes the shell to exit with the exit status specified by n.  If
  10473.           n is omitted then the exit status is that of the last command
  10474.           executed.  An end-of-file will also cause the shell to exit except
  10475.           for a shell which has the ignoreeof option (see set below) turned
  10476.           on.              
  10477.  
  10478.      exit [name]
  10479.           The given names are marked for automatic export to the       
  10480.           environment of subsequently-executed commands.               
  10481.                                                                        
  10482.      fc [ -e ename  ] [ -nlr ] [ first ] [ last ]                      
  10483.      fc -e -  [ old=new ] [ command ]                                  
  10484.           In the first form, a range of commands from first to         
  10485.           last is selected from the last HISTSIZE commands that        
  10486.           were typed at the terminal.  The arguments first and         
  10487.           last may be specified as a number or as a string.  A
  10488.           string is used to locate the most recent command             
  10489.           starting with the given string.  A negative number is        
  10490.           used as an offset to the current command number.  If         
  10491.           the flag -l, is selected, the commands are listed on         
  10492.           standard output.  Otherwise, the editor program ename        
  10493.           is invoked on a file containing these keyboard               
  10494.           commands.  If ename is not supplied, then the value of      
  10495.           the parameter FCEDIT (default /bin/ed) is used as the       
  10496.           editor.  When editing is complete, the edited               
  10497.           command(s) is executed. If last is not specified, it        
  10498.           will be set to first.  If first is not specified the        
  10499.           default is the previous command for editing and -16 for     
  10500.           listing.  The flag -r reverses the order of the             
  10501.           commands and the flag -n suppresses command numbers         
  10502.           when listing.  In the second form the most recent           
  10503.           command in the history whose first letters match            
  10504.           command is re-executed after the substitution old=new       
  10505.           is performed.                                               
  10506.                                                                       
  10507.      fg [ %job ]                                                      
  10508.           This command is only built-in on systems that support       
  10509.           job control.  If job is specified, it brings it to the      
  10510.           foreground.  Otherwise, the current job is brought into     
  10511.           the foreground.                                             
  10512.                                                                       
  10513.      jobs [ -l ]                                                      
  10514.           Lists the active jobs; given the -l option lists            
  10515.           process id's in addition to the normal information.         
  10516.                                                                       
  10517.      kill [ -sig ] process ...                                        
  10518.           Sends either the TERM (terminate) signal or the             
  10519.           specified signal to the specified jobs or processes.        
  10520.           Signals are either given by number or by names (as          
  10521.           given in <signal.h>, stripped of the prefix "SIG").         
  10522.           The signal names are listed by 'kill -l'.  There is no      
  10523.           default, saying just 'kill' does not send a signal to       
  10524.           the current job.  If the signal being sent is TERM          
  10525.           (terminate) or HUP (hangup), then the job or process        
  10526.           will be sent a CONT (continue) signal if it is stopped.     
  10527.           The argument process can be either a process id or a
  10528.           job.                                                         
  10529.                                                                        
  10530.      let  arg ...                                                      
  10531.           Each arg is an arithmetic expression to be evaluated.        
  10532.           All calculations are done as long integers and no check      
  10533.           for overflow is performed.  Expressions consist of           
  10534.           constants, named parameters, and operators.  The             
  10535.           following set of operators, listed in order of               
  10536.           decreasing precedence, are implemented:                      
  10537.           -         unary minus                                        
  10538.           !         logical negation                                   
  10539.           *  /  %   multiplication, division, remainder                
  10540.           +  -      addition, subtraction                              
  10541.           <  >      comparison                                         
  10542.           ==  !=    equality  inequality                               
  10543.           =         arithmetic replacement                             
  10544.                                                                        
  10545.           Sub-expressions in parentheses () are evaluated first        
  10546.           and can be used to override the above precedence rules.      
  10547.           The evaluation within a precedence group is from right       
  10548.           to left for the = operator and from left to right for        
  10549.           the others.                                                  
  10550.                                                                        
  10551.           A parameter name must be a valid identifier.  When a
  10552.           parameter is encountered, the value associated with the      
  10553.           parameter name is substituted and expression evaluation      
  10554.           resumes.  Up to nine levels of recursion are permitted.      
  10555.           The return code is 0 if the value of the last                
  10556.           expression is non-zero, and 1 otherwise.                     
  10557.                                                                        
  10558.                                                                        
  10559.      newgrp [ arg ... ]                                                
  10560.           Equivalent to exec newgrp arg ....                           
  10561.                                                                        
  10562.      print [ -Rnprsu[n ]  ] [ arg ... ]                                
  10563.           The shell output mechanism.  With no flags or with flag      
  10564.           -, the arguments are printed on standard output as           
  10565.           described by echo(1).  In raw mode, -R or -r, the            
  10566.           escape conventions of echo are ignored.  The -R option       
  10567.           will print all subsequent arguments and options other         
  10568.           than -n.  The -p option causes the arguments to be            
  10569.           written onto the pipe of the process spawned with |&          
  10570.           instead of standard output.  The -s option causes the         
  10571.           arguments to be written onto the history file instead         
  10572.           of standard output.  The -u flag can be used to specify       
  10573.           a one digit file descriptor unit number n on which the        
  10574.           output will be placed.  The default is 1.  If the flag        
  10575.           -n is used, no new-line is added to the output.               
  10576.                                                                         
  10577.      read [ -prsu[ n ] ] [ name?prompt ] [ name ... ]                   
  10578.           The shell input mechanism.  One line is read and is           
  10579.           broken up into words using the characters in IFS as           
  10580.           separators.  In raw mode, -r, a \ at the end of a line        
  10581.           does not signify line continuation.  The first word is        
  10582.           assigned to the first name, the second word to the            
  10583.           second name, etc., with leftover words assigned to the        
  10584.           last name.  The -p option causes the input line to be         
  10585.           taken from the input pipe of a process spawned by the         
  10586.           shell using |&.  If the -s flag is present, the input         
  10587.           will be saved as a command in the history file.  The          
  10588.           flag -u can be used to specify a one digit file               
  10589.           descriptor unit to read from.  The file descriptor can        
  10590.           be opened with the exec special command.  The default         
  10591.           value of n is 0.  If name is omitted then REPLY is used       
  10592.           as the default name.  The return code is 0 unless an          
  10593.           end-of-file is encountered.  An end-of-file with the -p       
  10594.           option causes cleanup for this process so that another        
  10595.           can be spawned.  If the first argument contains a ?,          
  10596.           the remainder of this word is used as a prompt when the       
  10597.           shell is interactive.  If the given file descriptor is        
  10598.           open for writing and is a terminal device then the            
  10599.           prompt is placed on this unit.  Otherwise the prompt is       
  10600.           issued on file descriptor 2.  The return code is 0            
  10601.           unless an end-of-file is encountered.                         
  10602.                                                                         
  10603.      readonly [ name ... ]                                              
  10604.           The given names are marked readonly and these names          
  10605.           cannot be changed by subsequent assignment.                  
  10606.                                                                        
  10607.      return [ n ]                                                      
  10608.           Causes a shell function to return to the invoking            
  10609.           script with the return status specified by n.  If n is       
  10610.           omitted then the return status is that of the last           
  10611.           command executed.  If return is invoked while not in a
  10612.           function then it is the same as an exit.                     
  10613.                                                                        
  10614.      set [ -aefhkmnostuvx ] [ -o option ... ] [ arg ... ]              
  10615.           The flags for this command have meaning as follows:          
  10616.           -a      All subsequent parameters that are defined are       
  10617.                   automatically exported.                              
  10618.           -e      If the shell is non-interactive and if a
  10619.                   command fails, execute the ERR trap, if set,         
  10620.                   and exit immediately.  This mode is disabled         
  10621.                   while reading profiles.                              
  10622.           -f      Disables file name generation.                       
  10623.           -h      Each command whose name is an identifier             
  10624.                   becomes a tracked alias when first encountered.      
  10625.           -k      All parameter assignment arguments are placed        
  10626.                   in the environment for a command, not just           
  10627.                   those that precede the command name.                 
  10628.           -m      Background jobs will run in a separate process       
  10629.                   group and a line will print upon completion.         
  10630.                   The exit status of background jobs is reported       
  10631.                   in a completion message.  On systems with job        
  10632.                   control, this flag is turned on automatically        
  10633.                   for interactive shells.                              
  10634.           -n      Read commands but do not execute them.               
  10635.           -o      The following argument can be one of the             
  10636.                   following option names:                              
  10637.                   allexport  Same as -a.                               
  10638.                   errexit    Same as -e.                               
  10639.                   emacs      Puts the user in an emacs style in-       
  10640.                              line editor for command entry.            
  10641.                   gmacs      Puts the user in a gmacs style in-        
  10642.                              line editor for command entry.            
  10643.                   ignoreeof  The shell will not exit on end-of-        
  10644.                              file.  The command exit must be           
  10645.                              used.                                     
  10646.                   keyword    Same as -k.                               
  10647.                   markdirs   All directory names resulting from        
  10648.                              file name generation have a trailing      
  10649.                              / appended.                               
  10650.                   monitor    Same as -m.                               
  10651.                   noexec     Same as -n.                               
  10652.                   noglob     Same as -f.                               
  10653.                   nounset    Same as -u.                               
  10654.                   verbose    Same as -v.                               
  10655.                   trackall   Same as -h.                               
  10656.                   vi         Puts the user in insert mode of a vi      
  10657.                              style in-line editor until hitting        
  10658.                              the escape character 033.  This puts      
  10659.                              the user in move mode.  A return          
  10660.                              sends the line.                           
  10661.                   viraw      Each character is processed as it is      
  10662.                              typed in vi mode.                         
  10663.                   xtrace     Same as -x.                               
  10664.                   If no option name is supplied then the current       
  10665.                   option settings are printed.                         
  10666.           -s      Sort the positional parameters.                      
  10667.           -t      Exit after reading and executing one command.        
  10668.           -u      Treat unset parameters as an error when              
  10669.                   substituting.                                        
  10670.           -v      Print shell input lines as they are read.            
  10671.           -x      Print commands and their arguments as they are       
  10672.                   executed.                                            
  10673.           -       Turns off -x and -v flags and stops examining        
  10674.                   arguments for flags.                                 
  10675.           --      Do not change any of the flags; useful in            
  10676.                   setting $1 to a value beginning with -.  If no       
  10677.                   arguments follow this flag then the positional       
  10678.                   parameters are unset.                                
  10679.                                                                        
  10680.           Using + rather than - causes these flags to be turned        
  10681.           off.  These flags can also be used upon invocation of        
  10682.           the shell.  The current set of flags may be found in         
  10683.           $-.  The remaining arguments are positional parameters       
  10684.           and are assigned, in order, to $1, $2, ....  If no           
  10685.           arguments are given then the values of all names are         
  10686.           printed on the standard output.                              
  10687.                                                                        
  10688.      shift [ n ]                                                       
  10689.           The positional parameters from $n+1 ...  are renamed $1      
  10690.           ..., default n is 1.  The parameter n can be any             
  10691.           arithmetic expression that evaluates to a non-negative       
  10692.           number less than or equal to $#.                             
  10693.                                                                        
  10694.      test [ expr ]                                                     
  10695.           Evaluate conditional expression expr.  See test(1) for       
  10696.           usage and description.  The arithmetic comparison            
  10697.           operators are not restricted to integers.  They allow        
  10698.           any arithmetic expression.  Four additional primitive        
  10699.           expressions are allowed:                                     
  10700.           -L file                                                      
  10701.                True if file is a symbolic link.                        
  10702.           file1 -nt file2                                              
  10703.                True if file1 is newer than file2.                      
  10704.           file1 -ot file2                                              
  10705.                True if file1 is older than file2.                      
  10706.           file1 -ef file2                                              
  10707.                True if file1 has the same device and i-node            
  10708.                number as file2.                                        
  10709.                                                                        
  10710.      times                                                             
  10711.           Print the accumulated user and system times for the          
  10712.           shell and for processes run from the shell.                  
  10713.                                                                        
  10714.      trap [ arg ] [ sig ] ...                                          
  10715.           arg is a command to be read and executed when the shell      
  10716.           receives signal(s) sig.  (Note that arg is scanned once      
  10717.           when the trap is set and once when the trap is taken.)       
  10718.           Each sig can be given as a number or as the name of the      
  10719.           signal.  Trap commands are executed in order of signal       
  10720.           number.  Any attempt to set a trap on a signal that was      
  10721.           ignored on entry to the current shell is ineffective.        
  10722.           An attempt to trap on signal 11 (memory fault) produces      
  10723.           an error.  If arg is omitted or is -, then all trap(s)       
  10724.           sig are reset to their original values.  If arg is the       
  10725.           null string then this signal is ignored by the shell         
  10726.           and by the commands it invokes.  If sig is ERR then arg      
  10727.           will be executed whenever a command has a non-zero exit      
  10728.           code.  This trap is not inherited by functions.  If sig      
  10729.           is 0 or EXIT and the trap statement is executed inside       
  10730.           the body of a function, then the command arg is              
  10731.           executed after the function completes.  If sig is 0 or       
  10732.           EXIT for a trap set outside any function then the            
  10733.           command arg is executed on exit from the shell.  The         
  10734.           trap command with no arguments prints a list of              
  10735.           commands associated with each signal number.                 
  10736.                                                                        
  10737.      typeset [ -FLRZefilprtux[n ] [ name[ =value ]  ]  ... ]           
  10738.           Parameter assignments remain in effect after the             
  10739.           command completes.  When invoked inside a function, a
  10740.           new instance of the parameter name is created.  The  
  10741.           parameter value and type are restored when the function      
  10742.           completes.  The following list of attributes may be          
  10743.           specified:                                                   
  10744.           -F   This flag provides UNIX to host-name file mapping       
  10745.                on non-UNIX machines.                                   
  10746.           -L   Left justify and remove leading blanks from value.      
  10747.                If n is non-zero, it defines the width of the           
  10748.                field, otherwise it is determined by the width of       
  10749.                the value of first assignment.  When the parameter      
  10750.                is assigned, it is filled on the right with blanks      
  10751.                or truncated, if necessary, to fit into the field.      
  10752.                Leading zeros are removed if the -Z flag is also        
  10753.                set.  The -R flag is turned off.                        
  10754.           -R   Right justify and fill with leading blanks.  If n       
  10755.                is non-zero, it defines the width of the field,         
  10756.                otherwise it is determined by the width of the          
  10757.                value of first assignment.  The field is left           
  10758.                filled with blanks or truncated from the end if         
  10759.                the parameter is reassigned.  The L flag is turned      
  10760.                off.                                                    
  10761.           -Z   Right justify and fill with leading zeros if the        
  10762.                first non-blank character is a digit and the -L         
  10763.                flag has not been set.  If n is non-zero, it            
  10764.                defines the width of the field, otherwise it is         
  10765.                determined by the width of the value of first           
  10766.                assignment.                                             
  10767.           -e   Tag the parameter as having an error.  This tag is      
  10768.                currently unused by the shell and can be set or         
  10769.                cleared by the user.                                    
  10770.           -f   The names refer to function names rather than           
  10771.                parameter names.  No assignments can be made and        
  10772.                the only other valid flag is -x.                        
  10773.           -i   Parameter is an integer.  This makes arithmetic         
  10774.                faster.  If n is non-zero, it defines the output        
  10775.                arithmetic base, otherwise the first assignment         
  10776.                determines the output base.                             
  10777.           -l   All upper-case characters converted to lower-case.      
  10778.                The upper-case flag, -u is turned off.                  
  10779.           -p   The output of this command, if any,  is written         
  10780.                onto the two-way pipe.                                  
  10781.           -r   The given names are marked readonly and these           
  10782.                names cannot be changed by subsequent assignment.       
  10783.           -t   Tags the named parameters.  Tags are user               
  10784.                definable and have no special meaning to the            
  10785.                shell.                                                  
  10786.           -u   All lower-case characters are converted to upper-       
  10787.                case characters.  The lower-case flag, -l is            
  10788.                turned off.                                             
  10789.           -x   The given names are marked for automatic export to      
  10790.                the environment of subsequently-executed commands.      
  10791.                                                                        
  10792.           Using + rather than - causes these flags to be turned        
  10793.           off.  If no name arguments are given but flags are           
  10794.           specified, a list of names (and optionally the values )      
  10795.           of the parameters which have these flags set is              
  10796.           printed.  (Using + rather than - keeps the values to be      
  10797.           printed.) If no names and flags are given, the names         
  10798.           and attributes of all parameters are printed.                
  10799.                                                                        
  10800.      ulimit [ -cdfmpt ] [ n ]                                          
  10801.           -c   Imposes a size limit of n blocks on the size of         
  10802.                core dumps (not on UMAX V).                             
  10803.           -d   Imposes a size limit of n blocks on the size of         
  10804.                the data area (not on UMAX V).                          
  10805.           -f   Imposes a size limit of n blocks on files written       
  10806.                by child processes (files of any size may be            
  10807.                read).                                                  
  10808.           -m   Imposes a soft limit of n blocks on the size of         
  10809.                physical memory (not on UMAX V).                        
  10810.           -p   Changes the pipe size to n (not on UMAX V).             
  10811.           -t   Imposes a time limit of n seconds to be used by         
  10812.                each process (not on UMAX V).                           
  10813.                                                                        
  10814.           If no option is given, -f is assumed.  If n is not           
  10815.           given, the current limit is printed.                         
  10816.                                                                        
  10817.      umask [ nnn ]                                                     
  10818.           The user file-creation mask is set to nnn (see               
  10819.           umask(2)).  If nnn is omitted, the current value of the      
  10820.           mask is printed.                                             
  10821.                                                                        
  10822.      unalias name ...                                                  
  10823.           The  parameters given by the list of names are removed       
  10824.           from the alias list.                                         
  10825.                                                                        
  10826.      unset [ -f ] name ...                                             
  10827.           The parameters given by the list of names are                
  10828.           unassigned, i.e., their values and attributes are            
  10829.           erased.  Readonly variables cannot be unset.  If the         
  10830.           flag, -f, is set, then the names refer to function           
  10831.           names.                                                       
  10832.                                                                        
  10833.      wait [ n ]                                                        
  10834.           Wait for the specified process and report its                
  10835.           termination status.  If n is not given then all              
  10836.           currently active child processes are waited for.  The        
  10837.           return code from this command is that of the process         
  10838.           waited for.                                                  
  10839.                                                                        
  10840.      whence [ -v ] name ...                                            
  10841.           For each name, indicate how it would be interpreted if       
  10842.           used as a command name.                                      
  10843.                                                                        
  10844.      The flag, -v, produces a more verbose report.                     
  10845.                                                                        
  10846.    Invocation.                                                         
  10847.      If the shell is invoked by exec(2), and the first character       
  10848.      of argument zero ($0) is -, then the shell is assumed to be       
  10849.      a login shell and commands are read from /etc/profile and         
  10850.      then from either .profile in the current directory or             
  10851.      $HOME/.profile, if either file exists.  Next, commands are        
  10852.      read from the file named by performing parameter                  
  10853.      substitution on the value of the environment parameter ENV        
  10854.      (for instance, $HOME/.kshrc set in $HOME/.profile) if the         
  10855.      file exists.  Commands are then read as described below; the      
  10856.      following flags are interpreted by the shell when it is           
  10857.      invoked:                                                          
  10858.                                                                        
  10859.      -c string If the -c flag is present then commands are read        
  10860.                from string.                                            
  10861.      -s        If the -s flag is present or if no arguments            
  10862.                remain then commands are read from the standard         
  10863.                input.  shell output, except for the output of          
  10864.                some of the Special Commands listed above, is           
  10865.                written to file descriptor 2.                           
  10866.      -i        If the -i flag is present or if the shell input         
  10867.                and output are attached to a terminal, this shell       
  10868.                is interactive.  In this case TERMINATE is ignored      
  10869.                (so that kill 0 does not kill an interactive            
  10870.                shell) and INTERRUPT is caught and ignored (so          
  10871.                that wait is interruptible).  In all cases, QUIT        
  10872.                is ignored by the shell.                                
  10873.                                                                        
  10874.      -r        If the -r flag is present the shell is a
  10875.                restricted shell.                                       
  10876.                                                                        
  10877.      The remaining flags and arguments are described under the         
  10878.      set command above.                                                
  10879.                                                                        
  10880.    rksh Only.                                                          
  10881.      rksh is used to set up login names and execution                  
  10882.      environments whose capabilities are more controlled than          
  10883.      those of the standard shell.  The actions of rksh are             
  10884.      identical to those of ksh, except that the following are          
  10885.      disallowed:                                                       
  10886.           changing directory (see cd(1)),                              
  10887.           setting the value of SHELL or PATH,                          
  10888.           specifying path or command names containing /,               
  10889.           redirecting output (> and >>).                               
  10890.                                                                        
  10891.      The restrictions above are enforced after .profile and the        
  10892.      ENV files are interpreted.                                        
  10893.                                                                        
  10894.      When a command to be executed is found to be a shell              
  10895.      procedure, rksh invokes ksh to execute it.  Thus, it is           
  10896.      possible to provide to the end-user shell procedures that         
  10897.      have access to the full power of the standard shell, while        
  10898.      imposing a limited menu of commands; this scheme assumes          
  10899.      that the end-user does not have write and execute                 
  10900.      permissions in the same directory.                                
  10901.                                                                        
  10902.      The net effect of these rules is that the writer of the           
  10903.      .profile has complete control over user actions, by               
  10904.      performing guaranteed setup actions and leaving the user in       
  10905.      an appropriate directory (probably not the login directory).      
  10906.                                                                        
  10907.      The system administrator often sets up a directory of             
  10908.      commands (i.e., /usr/rbin) that can be safely invoked by          
  10909.      rksh.  Some systems also provide a restricted editor              
  10910.      /bin/red.                                                         
  10911.                                                                        
  10912. EXIT STATUS                                                            
  10913.      Errors detected by the shell, such as syntax errors, cause        
  10914.      the shell to return a non-zero exit status.  If the shell is      
  10915.      being used non-interactively then execution of the shell          
  10916.      file is abandoned.  Otherwise, the shell returns the exit         
  10917.      status of the last command executed (see also the exit            
  10918.      command above).                                                   
  10919.                                                                        
  10920. FILES                                                                  
  10921.      /etc/passwd                                                       
  10922.      /etc/profile                                                      
  10923.      $HOME/.profile                                                    
  10924.      $HOME/.kshrc                                                      
  10925.      /tmp/sh*                                                          
  10926.      /dev/null                                                         
  10927.                                                                        
  10928. SEE ALSO                                                               
  10929.      cat(1), cd(1), echo(1), emacs(1), env(1), gmacs(1),               
  10930.      newgrp(1), shl(1), test(1), umask(1), vi(1).                      
  10931.      dup(2), exec(2), fork(2), pipe(2), signal(2), umask(2),           
  10932.      ulimit(2), wait(2), rand(3C), a.out(4), profile(4) in the         
  10933.      UMAX V Programmer's Reference Manual.                             
  10934.      environ(7) in the UMAX V Administrator's Reference Manual.        
  10935.                                                                        
  10936. CAVEATS                                                                
  10937.      If a command which is a tracked alias is executed, and then       
  10938.      a command with the same name is installed in a directory in       
  10939.      the search path before the directory where the original           
  10940.      command was found, the shell will continue to exec the            
  10941.      original command.  Use the -t option of the alias command to      
  10942.      correct this situation.                                           
  10943.                                                                        
  10944.      If moving the current directory or one above it, pwd may not      
  10945.      give the correct response.  Use the cd command with a full        
  10946.      path name to correct this situation.                              
  10947.                                                                        
  10948.      Some very old shell scripts contain a ^ as a synonym for the      
  10949.      pipe character |.                                                 
  10950.  
  10951.  
  10952.                                NOTES
  10953. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  10954.                                NOTES
  10955. èèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèèè
  10956.                                INDEX
  10957.  
  10958.  
  10959. .netrc file...................................................146
  10960. .profile.......................................................14
  10961. Backslash......................................................13
  10962. BourneShell.....................................................1
  10963. Child process..................................................39
  10964. Chmod...........................................................4
  10965. Exclamation mark (!)...........................................46
  10966. Grave accent marks.............................................36
  10967. HOME variable..................................................14
  10968. Internal-field separator.......................................15
  10969. Interpreter.....................................................1
  10970. Logical AND operator...........................................46
  10971. Logical OR operator............................................46
  10972. Object programs................................................67
  10973. Parent process.................................................39
  10974. Pound symbol (#)...............................................38
  10975. Prompt.........................................................17
  10976. Quote marks....................................................13
  10977. Secondary prompt...............................................17
  10978. Trace...........................................................2
  10979.